Question

I am trying to show bio and other custom metadata for my users in a page. So, i want to query the user metadata table for it. I have tried but did not find any functions for that.

What i am looking is getting all info doing a single database call.

This is what I have done so far:

    $wp_user_search = new WP_User_Query( array( 'role' => 'agent', 'fields' => 'all_with_meta') );
    $agents = $wp_user_search->get_results();

foreach($agents as $agent){
  var_dump($agent);
}

Result:

    object(WP_User)#235 (7) { ["data"]=> object(stdClass)#233 (10) 
{ ["ID"]=> string(1) "2" ["user_login"]=> string(8) "test" ["user_pass"]=> string(34) "$P$BmGqM9h7Ct7fasdfsdf5bdBUnTIYeW.wI4AUIZ0" ["user_nicename"]=> string(8) "prionkor" ["user_email"]=> string(16) "sisir@tutrem.com" ["user_url"]=> string(26) "http://barnesandklatt.com/" ["user_registered"]=> string(19) "2011-12-19 13:17:27" ["user_activation_key"]=> string(0) "" ["user_status"]=> string(1) "0" ["display_name"]=> string(8) "prionkor" } ["ID"]=> int(2) ["caps"]=> array(1) { ["agent"]=> string(1) "1" } ["cap_key"]=> string(15) "wp_capabilities" ["roles"]=> array(1) { [0]=> string(5) "agent" } ["allcaps"]=> array(2) { ["read"]=> bool(true) ["agent"]=> string(1) "1" } ["filter"]=> NULL } 

But it seems i am not getting all meta data Bio and other custom ones i have added (like twitter, facebook, phone etc.)

Please let me know if you have any advice. Thanks!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top