Change WordPress user roles and capabilities › Forums › Bug Reports › Issue with Yoast SEO (multiple versions also with Pro)
Tagged: Yoast
- This topic has 3 replies, 2 voices, and was last updated 6 years, 6 months ago by
Vladimir.
-
AuthorPosts
-
12/04/2019 at 07:33 #5633
PROMOINVIDEO
ParticipantWe 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 redirectsThanks for your support.
12/04/2019 at 14:46 #5634Vladimir
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.
15/04/2019 at 16:48 #5637PROMOINVIDEO
ParticipantThanks 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 redirectsbut not
Wpseo edit advanced metadata
….I honestly didn’t understand the reason
16/04/2019 at 05:42 #5639Vladimir
KeymasterIt 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; } -
AuthorPosts
- You must be logged in to reply to this topic.