Allowing authors to set co-authors

In the WordPress.org forums, whoaloic asks:

I have a site with multiple authors.
I would like to allow authors who create a post or a page to give rights to other authors.
For now, only administrator and editor can do that.
Is there a solution?

Yep, totally doable. By default, Co-Authors Plus defaults to ‘edit_others_posts’ as the required cap for changing co-authors. With the following code snippet in your theme’s functions.php file, you can make that cap ‘publish_posts’ instead (which authors and above usually have).

/**
 * Filter the Co-Authors Plus current_user_can_set_authors() function
 * so that users with 'publish_posts' can set Co-Authors
 *
 * @author danielbachhuber
 *
 * @see https://github.com/danielbachhuber/Co-Authors-Plus/issues/8
 * @see http://wordpress.org/support/topic/plugin-co-authors-plus-allow-authors-post-to-give-access-to-other-authors
 */
add_filter( 'coauthors_plus_edit_authors', 'db_filter_coauthors_edit_cap' );
function db_filter_coauthors_edit_cap( $cap_result ) {
	global $coauthors_plus;

	$post_type = $coauthors_plus->get_current_post_type();
	if( ! $post_type ) return false;
	
	$post_type_object = get_post_type_object( $post_type );
	return current_user_can( $post_type_object->cap->publish_posts );
}

In preparing this snippet, I also opened a couple of issues in Github:

0 thoughts on “Allowing authors to set co-authors

  1. This is now broken with 3.0.4 version of co-authors-plus. Could you post an updated snippet?

  2. I’ll bump this! Would love to be able to use this capability with our ‘Authors’, but right now the snippet is broken with the new version.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>