I have a php file for fetching the user details from the wordpress database. for that I've coded like this
$users = new WP_User_Query( array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'first_name', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'last_name', 'value' => '', 'compare' => 'LIKE' ) ) ) ); $$result = $users->get_results();
echo " Roll No Name Address Stream Status"; while($data = mysql_fetch_row($result)) { echo ""; echo "$data[0]"; echo "$data[1]"; echo "$data[2]"; echo "$data[3]"; echo "$data[4]"; echo ""; } echo ""; ?>
but it shows error that Fatal error: Class 'WP_User_Query' not found in C:\wamp\www.... how do solve this , help me
You're running this too early context — the class isn't loaded yet.
Try running your code on the wp_loaded
hook, e.g.:
add_action('wp_loaded', function() {
// code goes here
});