admin管理员组文章数量:1322850
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?
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?
Share Improve this question edited Sep 17, 2020 at 19:17 Sev. asked Sep 12, 2020 at 14:21 Sev.Sev. 32 bronze badges 1- The cause of that warning is not in the code block you added – Tom J Nowell ♦ Commented Sep 13, 2020 at 0:02
1 Answer
Reset to default 1Somewhere 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>
本文标签: callbacksCode worksbut warning about calluserfuncarray() appears
版权声明:本文标题:callbacks - Code works, but warning about call_user_func_array() appears 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742113955a2421382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论