-
Notifications
You must be signed in to change notification settings - Fork 206
Creating and editing guest authors
Guest authors can be created and managed under “Users” -> “Guest Authors”. Guest author data is created and stored as a guest_author
custom post type.
Guest authors can be aded as bylines without creating WordPress user accounts for them. Each guest author can have many of same fields a normal WordPress user would typically have, including display name, email address, and website. You can assign a featured image in order to override the avatar typically associated with the email address.
Once you’ve created your guest author, their byline can be assigned to a post using the normal Co-Authors Plus interface.
To create new guest author profiles, a WordPress user must have the list_users
capability. This is typically granted to the Administrator role, but can be altered with the coauthors_guest_author_manage_cap
filter.
To assign co-authors to posts, a WordPress user must have the edit_others_posts
capability. This is typically granted to the Editor role, but can be altered with the coauthors_plus_edit_authors
filter.
When a user is deleted from WordPress, they will be removed from all posts for which they are co-authors. If you chose to reassign their posts to another user, that user will be set as the coauthor instead.
The default set of profile fields can easily be manipulated using accessible filters. To place your field in one of the existing post meta boxes, use something similar to this example:
<php
/**
* Add a "Google Plus" field to Co-Authors Plus Guest Author
*/
add_filter( 'coauthors_guest_author_fields', 'capx_filter_guest_author_fields', 10, 2 );
function capx_filter_guest_author_fields( $fields_to_return, $groups ) {
if ( in_array( 'all', $groups ) || in_array( 'contact-info', $groups ) ) {
$fields_to_return[] = array(
'key' => 'google_plus',
'label' => 'Google Plus',
'group' => 'contact-info',
);
}
return $fields_to_return;
}
Then, for use on the frontend, the new field is automatically loaded onto the $coauthor object.
If you’re performing a migration of users to co-author guest authors, there are a couple of helpful wp-cli commands packaged with the plugin:
-
wp co-authors-plus create-guest-authors
will create guest authors for all of your existing users -
wp co-authors-plus assign-user-to-coauthor
will then assign all of the posts associated with old user to your new guest author
Steps to migrate all users/authors to a site:
- Install the Co-Authors Plus plugin on a staging site.
- Run the create-guest-authors CLI command to create the Guest Authors automatically.
- Export Guest Authors from the "Tools"-->"Export" screen of your staging site. Save the resulting WXR file. The WP-CLI guest authors will be included in this export.
- Create a mapping CSV file for editorial users who require real logins from their login on the staging site to their login on the production site (these may or may not be be the same). The CSV file format should be:
johnsmith, johnsmithwp
janesmith, janesmith
johndoe, johndoe123
- Import both the WXR and CSV with the WP-CLI command
wp import
. The WordPress Import tool cannot be used for importing these files.