Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Code Snippet: Allow authors to change co-authors #104

Open
danielbachhuber opened this Issue Feb 2, 2013 · 2 comments

Comments

Projects
None yet
4 participants
Collaborator

danielbachhuber commented Feb 2, 2013

Once we finish #103, we should write a code snippet to show users how to let their authors change co-authors

Requests:

I stumbled upon this myself, so if there's anything I could help, please drop me a note.
I didn't dive deep enough into the plugin code yet, but shouldn't it work to add coauthors_plus_edit_authors as a privilege to user accounts (true by defaulf for editor role and above) and handle that instead of or additionally to the other ones in current_user_can_set_authors() (co-authors-plus.php)?
If somebody would confirm that this is all that has to be done, I probably could make patch.

@danielbachhuber danielbachhuber modified the milestones: next, 3.1 Mar 14, 2014

@philipjohn philipjohn removed this from the next milestone Dec 3, 2016

Collaborator

rebeccahum commented Jul 21, 2017

I fixed the current snippet to work:

add_filter( 'coauthors_plus_edit_authors', 'filter_coauthors_edit_cap', 10, 2 );

function filter_coauthors_edit_cap( $cap_result ) {
	global $coauthors_plus;

	$post_type = get_current_screen()->post_type;

	if( empty ( $post_type ) ) {
		return false;
	}

	$post_type_object = get_post_type_object( $post_type );

	return current_user_can( $post_type_object->cap->publish_posts );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment