CAP hooks into some of the core WordPress functions for displaying author information. But, if you have anything custom and you want to get the author object, its a little tough to obtain.
This also contains a test for whether or not a coauthor is a guest author, which determines if they have any of the custom data that is only appended to Guest Author profiles.
We handled this similarly on Creepy Catalog and Shop Catalog
/**
* CoAuthor is Guest Author
* Is this coauthor an object where the type value is 'guest-author'?
*
* @param object $coauthor Object to test.
* @return bool Whether or not the object passed the test.
*/
function creepycatalog_coauthor_is_guest_author( $coauthor ) : bool {
return 'guest-author' === creepycatalog_safe_get_object_property( 'type', $coauthor );
}
/**
* Get Global Guest Author
*
* @global $coauthors_plus
* @return mixed {object|WP_User|false}
*/
function creepycatalog_get_global_guest_author() {
global $coauthors_plus;
$author_name = sanitize_user( get_query_var( 'author_name' ) );
return $coauthors_plus->get_coauthor_by( 'user_nicename', $author_name );
}
/**
* Has Global Guest Author
*
* @return bool Whether author_name query variable is associated with a Guest Author.
*/
function creepycatalog_has_global_guest_author() : bool {
return creepycatalog_coauthor_is_guest_author(
creepycatalog_get_global_guest_author()
);
}
CAP hooks into some of the core WordPress functions for displaying author information. But, if you have anything custom and you want to get the author object, its a little tough to obtain.
This also contains a test for whether or not a coauthor is a guest author, which determines if they have any of the custom data that is only appended to Guest Author profiles.
We handled this similarly on Creepy Catalog and Shop Catalog