Question

I'm a newbie to Wordpress. I'm trying to make custom page that displays contact info for all users. I use code snippet provided by THIS POST.

<ul>
<?php
    $blogusers = get_users('blog_id=1&orderby=nicename');
    foreach ($blogusers as $user) {
        echo '<li>Nick: ' . $user->user_nicename . '</li>';
        echo '<li>Name: ' . $user->display_name. '</li>';
        echo '<li>Email: ' . $user->user_email. '</li>';
    }
?>
</ul>

It works, but it also shows this warning at the top:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'yoursite_pre_user_query' not found or invalid function name in C:\xampp\htdocs\mytheme\wordpress\wp-includes\class-wp-hook.php on line 287

What should I do to resolve this?

Was it helpful?

Solution

Somewhere in your theme or plugins, you must have a line like this add_action( 'something', 'yoursite_pre_user_query' ). Find it and remove or fix it.

Also, the get_users function has since been updated. Your first parameter must be an array.

<ul>
<?php
    $blogusers = get_users( array('blog_id' => 1, 'orderby' => 'nicename') );
    foreach ( $blogusers as $user ) {
        echo '<li>Nick: ' . $user->user_nicename . '</li>';
        echo '<li>Name: ' . $user->display_name. '</li>';
        echo '<li>Email: ' . $user->user_email. '</li>';
    }
?>
</ul>
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top