Support » Developing with WordPress » How to fetch all information of Users

  • I am trying to fetch users All information by using below code.

    
    if($_POST['orga_id']) {
    		$users_query = new WP_User_Query(array(
    			'meta_query' => array(
    				'relation' => 'AND',
    				array(
    					'relation' => 'OR',
    					array(
    						'key'     => 'first_name',
    						'value'   => $_POST['search'],
    						'compare' => 'LIKE'
    					),
    					array(
    						'key' 		=> 'last_name',
    						'value' 	=> $_POST['search'],
    						'compare' 	=> 'LIKE',
    					),
    				),
    				array(
    					'key' 		=> 'organisation',
    					'value' 	=> $_POST['orga_id'],
    					'compare' 	=> 'LIKE',
    				),
    				array(
    					'key' 		=> 'available',
    					'value' 	=>  1,
    					'compare' 	=> '=',
    				),			
    			)
    		));
    	} else {
    		$users_query = new WP_User_Query(array(
    			'meta_query' => array(
    				'relation' => 'AND',
    				array(
    					'relation' => 'OR',
    					array(
    						'key'     => 'first_name',
    						'value'   => $_POST['search'],
    						'compare' => 'LIKE'
    					),
    					array(
    						'key' 		=> 'last_name',
    						'value' 	=> $_POST['search'],
    						'compare' 	=> 'LIKE',
    					),
    				),
    				array(
    					'key' 		=> 'available',
    					'value' 	=>  1,
    					'compare' 	=> '=',
    				),			
    			)
    		));
    	}
    
    	//$users_found = $users->get_results();
    
    	$args = array(
    		'fields' => 'all',
    		'orderby'     => array( 'last_name' => 'asc', 'first_name' => 'asc' ),
    		'meta_query' => $users_query,
    	);
    
    	$users2 = get_users($args);
    

    But I am getting only few information like below.

    
    ID: "548"
    ​​​​
    display_name: "AaronKew"
    ​​​​
    user_activation_key: ""
    ​​​​
    user_email: "aaron.kew@nsw.scouts.com.au"
    ​​​​
    user_login: "AaronKew"
    ​​​​
    user_nicename: "aaronkew"
    ​​​​
    user_pass: "$P$BauZua136ZxKPY9Nu2FpmZT1LRmOLr1"
    ​​​​
    user_registered: "2022-02-06 03:17:50"
    ​​​​
    user_status: "0"
    ​​​​
    user_url: ""
    

    I am not getting first_name and last_name of users.

    https://i.stack.imgur.com/JVYyb.png

    • This topic was modified 4 months, 2 weeks ago by mabufoysal.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.