php – when hooking to pre_user_query my wordpress crashes when using very simple commands?

Question

add_action('pre_user_query','yoursite_pre_user_query');
function yoursite_pre_user_query($user_search) {
  global $current_user;
  $username = $current_user->user_login;

//command 1
  //$args = array(
  //  'role'    => 'adminsub',
  //  'orderby' => 'user_nicename',
  //  'order'   => 'ASC'
  //);
  //$arrayofuserarray = get_users( $args );
  //print_r($arrayofuserarray);

//command 2
//  $blogusers = get_users( array( 'role__in' => array( 'author', 'subscriber' ) ) );
// Array of WP_User objects.
//foreach ( $blogusers as $user1 ) {
//    echo '<span>' . esc_html( $user1->display_name ) . '</span>';
//}

}

do I need to use a global variable to use get_users?
is it cause its pre_user_query? and if so, can I hook something else in?

0
danem 7 months 2022-01-30T07:58:49-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse