Site icon Hip-Hop Website Design and Development

WP_User_Query not returning customers with meta – what am I lacking?

I feel I am lacking a step right here, however for the lifetime of me I am unable to see it. I am making an attempt to show a easy listing of customers who all have the identical position and have the identical meta information worth for a sure key – particularly, lecturers related to a college.

Right here is my code:

    <div class="teachers-list">
            <h3>Your Faculty's Academics</h3>
            <ul>
                <?php

                $champion_user = wp_get_current_user();
                $faculty = $champion_user->faculty;

                // echo $faculty simply to check it is proper.... ?> 
                Your faculty: <?php echo $faculty; ?>

                <?php 


                $args = array( 
                     'position' => 'subscriber',
                     'meta_key'    => 'faculty',
                     'meta_value'  => $faculty
                );

                // The Question
                $user_query = new WP_User_Query( $args );

                // Consumer Loop
                if ( ! empty( $user_query->outcomes ) ) {
                    foreach ( $user_query->outcomes as $person ) {
                        echo '<li>' . $user->display_name . '</li>';
                    }
                } else {
                    echo '<li>No lecturers discovered.</li>';
                }
                ?>
            </ul>
        </div>  

The varsity variable echoes correctly, however then within the WP_User_Query I solely get the “no lecturers discovered” consequence. If I remark out the meta_key and meta_value fields, I get an inventory of subscribers, in order that far works. If I manually code within the meta_value I am searching for – on this case, “school_one”, it nonetheless returns “no lecturers discovered”. I checked the usermeta desk within the db and all of the customers have the college meta key and the right faculty values there, so… I am stumped.

I’ve learn and re-read the codex for each WP_User_Query() and get_user_meta(), and written this out each with the pre-WP 3.7 syntax and now the present syntax, however clearly I’ve missed the primary level to get this working. Do I must reset the question by some means? Do I would like the “evaluate” argument too? Am I utilizing the $faculty variable improperly within the arguments? I’ve tried so many strategies I am undecided what’s left.

Any assistance is drastically appreciated. Thanks prematurely for studying.