Change WordPress user roles and capabilities Forums Bug Reports Issue with Yoast SEO (multiple versions also with Pro)

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5633
    PROMOINVIDEO
    Participant

    We experience an issue with Yoast capabilities.
    Step to reproduce the problem:
    – activate Yoast SEO
    – In role editor (editor profile) enable all 4 capabilities and SAVE
    1-Wpseo bulk edit
    2-Wpseo edit advanced metadata
    3-Wpseo manage options
    4-Wpseo manage redirects
    – ALL WORKS WELL
    – Try to disable and re-enable YOAST SEO
    – In role editor you will see only the two main capabilities enabled:
    1-Wpseo bulk edit
    4-Wpseo manage redirects

    Thanks for your support.

    #5634
    Vladimir
    Keymaster

    “Yoast SEO” has own capabilities manager, which removes all wpseo capabilities on plugin deactivation and adds them to the pre-defined list of roles on plugin activation.
    There is a filter , using which it’s possible to tell “Yoast SEO” which capability to which role add/remove automatically on plugin activation/deactivation.

    
    /**
     * Filter: Allow changing roles that a capability is added to.
     *
     * @api array $roles The default roles to be filtered.
     */
    $filtered = apply_filters( $capability . '_roles', $roles );
    

    For example with code below you will have ‘wpseo_manage_options’ capability granted to ‘editor’ role automatically on “Yoast SEO” plugin activation:

    
    add_filter('wpseo_manage_options_roles', 'wpseo_manage_options_roles', 10, 1);
    
    function wpseo_manage_options_roles( $roles ) {
    
        $roles[] = 'editor';
    
        return $roles;
    }
    

    You may add it to the active theme functions.php file or setup it as a Must Use plugin.

    #5637
    PROMOINVIDEO
    Participant

    Thanks Vladimir for this useful suggestion. Using your code I reach to automatically enable 3 of 4 options. Do you know why?

    Wpseo bulk edit
    Wpseo manage options
    Wpseo manage redirects

    but not

    Wpseo edit advanced metadata

    ….I honestly didn’t understand the reason

    #5639
    Vladimir
    Keymaster

    It works at my side as expected. Try to use code below:

    
    add_filter('wpseo_edit_advanced_metadata_roles', 'wpseo_edit_advanced_metadata_roles', 10, 1);
    
    function wpseo_edit_advanced_metadata_roles( $roles ) {
    
        $roles[] = 'editor';
    
        return $roles;
    }
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.