Why is get_userdata not giving me the first name of my authors?
-
I’m trying to make a list of wordpress authors and be able to link to a customized author page for each one from a drop down menu within a plugin.
In order to do so, I’m trying to use the following code to be able to get all of the author ids and then extract the first names. For some reason I’m getting back some of the data such as display_name, but not information such as user_firstname. This code is modified but very similar to the code found in the wp_list_authors function.
By itself wp_list_authors does not give me enough freedom and information for what I’m trying to do.
Any thoughts? Thanks!
$query_args['orderby'] = 'name'; $query_args['order'] = 'ASC'; $query_args['fields'] = 'ids'; //$query_args['role'] = 'author'; $query_args['number'] = ''; $authors = get_users( $query_args ); foreach ( $authors as $author_id ) { $author = get_userdata( $author_id ); echo $author->user_firstname; //print_r($author); }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Why is get_userdata not giving me the first name of my authors?’ is closed to new replies.