Skip to content
WP Engine Developers

Authors

MediaPress Authors provides a solution for author attribution in WordPress, including multi-author and guest author functionality. This feature operates on the premise that authors and users are different entities and should be kept separate.

  • Authors are used for content attribution, which may or may not be the person adding the content within the CMS
  • Users are accounts within the CMS with permissions and roles that reflect their level of access

MediaPress Authors are managed as a taxonomy - similar to categories and tags - and separating authors from users has several advantages:

  • Multiple authors can be assigned to a single post
  • Guest authors never need to have a user account
  • If a user needs to be removed from the CMS, the authors set on any content they created will be unaffected
  • It’s easy to configure a generic/default author to attribute content to, if you don’t want a specific user name associated with posts

If you happen to be both a user and an author, you can set a default MediaPress Author in your user account, preventing the need to select this every time you create a new post.

Because WordPress users are traditionally treated as authors, several adjustments needed to ensure this works as expected:

  • User profile pages are disabled by default (you are expected to use author term pages to display posts related to a MediaPress author)
  • Custom blocks are available specifically for displaying MediaPress Author information in posts/templates
  • Post information is filtered so that the author term is used in place of the original author (user) where appropriate

A byline is used to attribute a piece of content to one or more authors. This is stored as post meta in addition to the taxonomy relationship linking MediaPress Authors to a post.

This allows a byline to remain static. For example, if an author has a specific job role ‘suffix’ associated with them, it will be saved within the byline, if that author information changes at a later date, the byline will reflect what it was at the time the post was created.

Allows adjustment of the arguments passed when registering the mediapress_authors taxonomy.

This may be used to:

  • Disable author profile pages (set public to false)
  • Adjust the rewrite permalinks for author profile pages (default is yoursite.com/profile/author-slug)
  • Adjust the default author term that is applied when no author is selected for a post (by setting default_term)

Parameters

NameTypeDescription
argsarrayThe arguments passed to register_taxonomy

Usage

// Adjust the author profile url to `yoursite.com/author/author-slug`
add_filter( 'mediapress_authors_taxonomy_args', 'my_plugin_author_profile_url' );
function my_plugin_profile_url( array $args ): array {
$args['rewrite']['slug'] = 'author';
return $args;
}
// Redefine the default author term
add_filter( 'mediapress_authors_taxonomy_args', 'my_plugin_default_author' );
function my_plugin_default_author( array $args ): array {
$args['default_term'] = [
'name' => __( 'Editorial Team', 'my-plugin' ),
'slug' => 'editorial-team',
'description' => __( 'Our hard-working editorial team', 'my-plugin' ),
];
return $args;
}
mediapress_authors_disable_core_author_page
Section titled “mediapress_authors_disable_core_author_page”

Disable the core author/user pages.

Parameters

NameTypeDescription
should_disableboolShould the core authors page be disabled

Usage

// Re-enable the core author page.
add_filter( 'mediapress_authors_disable_core_author_page', '__return_false' );

Excluded user roles when running the CLI migration

Parameters

NameTypeDescription
excluded_rolesarray<string>User roles to exclude from the migration

Usage

add_filter( 'mediapress_authors_excluded_user_roles', 'my_plugin_user_roles_excluded_from_author_migrations' );
function my_plugin_user_roles_excluded_from_author_migrations( $roles ) {
return array_merge( $roles, [ 'Author ] );
}

Should we create an author for the newly created user.

Parameters

NameTypeDescription
should_createboolShould we create an author
user_idintuser id to create author for
user_dataarray<string, string>The raw array of data passed to wp_insert_user.

Usage

add_filter(
'mediapress_authors_should_create_author',
'my_plugin_should_create_author',
10,
3,
);
function my_plugin_should_create_author( $should_create, $user_id, $user_data ): bool {
if ( ! $should_create ) {
return $should_create;
}
return $user_id !== 123 && $user_data['role'] !== 'author';
}

Migrate all WordPress users to MediaPress authors terms.

Migrate all WordPress users posts to MediaPress Authors

Terminal window
wp mediapress authors migrate posts [--per-page=<per-page>]
[--per-page=<per-page>]
Number of posts per page when assigning terms to posts

Create a MediaPress Author

Terminal window
wp mediapress authors create --name=<name> [--prefix=<prefix>] [--suffix=<suffix>]
[--user-id=<user-id>] [--avatar=<avatar>]
--name=<name>
Author Name
[--prefix=<prefix>]
Author's prefix e.g Dr
[--suffix=<suffix>]
Author's suffix e.g ', Digital Editor'
[--user-id=<user-id>]
User id to assign it to.
[--avatar=<avatar>]
Attachment id of author

Last updated: