• Resolved Ger

    (@lindt01)


    Scenario:
    1. Vanilla WordPress 5.5 out of the box with default theme 2020; content: sample page and sample post
    2. Log in as administrator
    3. Add and activate the plugin Members release 3.0.10
    4. Add and activate the plugin Classic Editor release 1.6
    5. Add a user called Tester with role Editor
    6. Quick Edit a page or a post
    7. You can change the Author to whatever user you want; dropdown shows both users; this also works in the block editor and classic editor
    8. Clone a role i.e. Editor Clone
    9. Assign this role to the user Tester and save the profile
    10. Quick Edit a page or post
    11. You now are unable to change the author; in block editor there is no possibility to change the author; in the classic editor the author dropdown shows only the administrator
    12. When you change the role of the user Tester back to Editor all works fine again and you can change the author to all existing users

    Can you please tell me if this is unexpected behaviour or a bug? Can you please assist me further?

    • This topic was modified 4 years, 6 months ago by Ger.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @lindt01

    Thank you for reporting this.

    I wasn’t able to duplicate this issue on my local installation but I’ve asked our Developer for investigating this issue. We’ll let you know once we finish tests.

    Cheers

    Thread Starter Ger

    (@lindt01)

    Hi Caseproof,

    Thanks a lot for your fast response. I will wait in patience for the results of your developer.

    Best regards,
    Ger

    Plugin Author Caseproof

    (@caseproof)

    We investigated this issue further and we couldn’t find any issues with Classic Editor. In Gutenberg, the Author dropdown is populated through a query to the REST API to fetch the authors. You’ll need to modify the REST query to add in the correct users. Please try to use this code:

    add_filter( 'rest_user_query', 'my_custom_rest_authors', 25, 2 );
    /**
     * Modifies the "authors" included in the REST response for /wp/v2/users/?who=authors
     *
     * @param  array 	$args    	Query args
     * @param  object 	$request 	REST request
     *
     * @return array
     */
    function my_custom_rest_authors( $args, $request ) {
    	
    	if ( ! empty( $request['who'] ) && 'authors' === $request['who'] ) {
    
    		// Customize which roles are considered authors
    		$rest_author_roles = array();
    
    		// Get registered roles
    		$roles = wp_roles();
    
    		// Check each role for the edit_posts capability
    		// Change this as needed
    		foreach ( $roles->roles as $key => $r ) {
    			$role = $roles->get_role( $key );
    			if ( $role->has_cap( 'edit_posts' ) ) {
    				$rest_author_roles[] = $key;
    			}
    		}
    		
    		$args['role__in'] = array_merge( ! empty( $args['role__in'] ) ? $args['role__in'] : array(), $rest_author_roles );
    		$args['who'] = '';
    	}
    
    	return $args;
    }

    Cheers

    Thread Starter Ger

    (@lindt01)

    Hi @caseproof,

    Thanks a lot for investigating. When I paste the above code in my child theme functions.php it works alright in Gutenberg. I can choose both users as the page/post author.0

    However in the Classic Editor and in Quick Edit I can only choose the administrator as the author? In my opinion there is still something not OK?

    Kind regards,
    Ger

    Plugin Author Caseproof

    (@caseproof)

    I switched to Classic Editor and I can choose Administrators, Editors, and Authors. I don’t see Cloned Editor but that’s because WordPress doesn’t display custom roles by default.

    Cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Clone role affects possibility to change an author’ is closed to new replies.