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:xampphtdocsmythemewordpresswp-includesclass-wp-hook.php on line 287
What should I do to resolve this?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0