Developer Support

You are here:
< Back
Table of Contents

Override userdata.

In version 3.0+, the author query for guest author post archives now returns the guest author data in the queried object field. You can add this code to your custom theme functions or override the pluggable get_userdata function by adding this code.

if ( is_author() )
{  
      
   global $wp_query;
   if ( isset($wp_query) && $wp_query->is_guest_author )
   {
            if ($wp_query->is_guest_author)
            {
                $userdata = $wp_query->get_queried_object();
            }
   }
}

Guest Author Avatar

gap_get_guest_avatar($id) //get the guest author avatar html

gap_get_guest_avatar_url($id) //get the url to the guest author avatar

Override the Guest Author Avatar in a post

To override the guest author avatar within a post, you need to set the guest_author_post_id to 0 or null before calling the function to get the avatar.

global $guest_author_post_id;     //global variable
$guest_author_save = $guest_author_post_id; //save the value
$guest_author_post_id=0; //clear the post id      
get_avatar( get_current_user_id(), 100 ) //now get the original avatar
$guest_author_post_id = $guest_author_save; //set the guest author post id back to what it was

Guest Author Helper Class

As of version 3.0, A helper class, guest-author-class.php is included with the plugin that allows you to get the userdata for a guest author. This file is located in the /helpers directory.

guest_author_class
object_id – (optional) default = current post id. This value can be any custom post id or a guest author id.
getauthor – (optional) default = false. Sets the value $class->authordata to the authors userdata.

guest_author_class( $object_id, $true );

Get the author data for the current post:

-Use the guest author class-
$class= guest_author_class( null, true );
$authordata = $class->authordata;
-or the global functions below -

Get authordata by author id

$authorid – the id for the author. Optional when an object id was sent to the class constructor..

$authorid = $class->get_guest_author_by_id ($authorid); 
-or the global function -
$authorid = gap_get_guest_author_by_id ($authorid);

Get authordata by post id

$post_id = the id for the post. Optional when an object id was sent to the class constructor.
$authurdata = $class->get_guest_author_by_post($post_id = null)
-or the global function-
authordata = gap_get_guest_author_by_post ( $post_id = null );

Get the guest id from a post

$post_id – the id for the post. Optional when an object id was sent to the class constructor.

$guest_id = $class->get_guest_author_id ($postid  = null);
-or the global function-
$guest_id = gap_get_guest_author_id($postid = null);

Get a meta value from the guest author

Possible meta values:

guest_author_website_link
guest_author_gravatar_email
‘facebook’, ‘twitter’, ‘linkedin’, ‘google-plus’, ‘googleplus’, ‘youtube’, ‘instagram’, ‘tumblr’, ‘pinterest’

The guest_id can be set to null to use the id that was set when the class was created. That information is based on the post id.

$meta_value = $class->get_guest_author_meta( $guest_id , $meta_key , $single=true )
-or the global function-
gap_get_guest_author_meta ($guest_id, $meta_key, $single=true);

Get the guest author website, email, description, name

These functions get an authors website, email, description or name.
The guest_id can be set to null to use the id that was set when the class was created. That information is based on the post id.
guest_id is optional if the object id was set in the class constructor.

$website = $class->guest_author_link($guest_id) -or the global function- gap_guest_author_link($guest_id);
$email = $class->guest_author_email($guest_id) -or the global function- gap_guest_author_email($guest_id);
$description = $class->guest_author_description($guest_id) -or the global function- gap_guest_author_description($guest_id);
$name = $class->guest_author_name($guest_id) -or the global function- gap_guest_author_name($guest_id);