- This topic has 37 replies, 3 voices, and was last updated 5 years, 1 month ago by
Arimateia Jr.
-
AuthorPosts
-
August 14, 2020 at 12:42 pm #1403186
Tom
Lead DeveloperLead DeveloperThanks for the reminder! I’ve added this filter in 1.12.0:
generate_elements_metabox_ajax_allow_editorsSo you should be able to do this:
add_filter( 'generate_elements_metabox_ajax_allow_editors', '__return_true' );Would be great if you can give it a test during the 1.12.0 beta period so we know it’s all good 🙂
Thanks again!
August 19, 2020 at 1:59 am #1409040Simon
Hi Tom,
Sorry I didn’t get to test this during the beta of 1.1.12
I tried it in 1.11.3 but it didn’t work. So I must be doing something wrong.
I am going to test it on another site and will feedback ASAP.
Thank you for including the filter.
**UPDATE**
So I tested in another site and it still doesn’t quite work. It almost does. Here is the code I am using including our new filter:
/* Add Access for Editor to GP Elements ------------------------------------------*/ add_filter( 'register_post_type_args', function( $args, $post_type ) { if ( 'gp_elements' === $post_type ) { $args['capability_type'] = 'post'; } return $args; }, 10, 2 ); /* Move Elements to Top Level Link to Allow Access ------------------------------------------*/ add_filter( 'register_post_type_args', function( $args, $post_type ) { if ( 'gp_elements' === $post_type ) { $args['show_in_menu'] = true; } return $args; }, 10, 2 ); add_filter( 'generate_elements_metabox_ajax_allow_editors', '__return_true' );The above allows the Editor access to Elements and moves the Elements into the Top Level WP nav so they can access it. Your filter gives the editor access to Pages/Posts etc. but it won’t generate the meta box for specifics.
I’ve included a screenshot showing what I mean.
Still, the only way I can get all the meta boxes to appear for an Editor is by altering the reference to manage_options in the class-metabox.php
Thanks for all your help on this.
Kind regards,
Simon
August 19, 2020 at 8:56 am #1409796Tom
Lead DeveloperLead DeveloperHi Simon,
This change will happen in 1.12.0 (not the 1.11.x patches).
We try to keep patches as simple as possible to ensure stability. Larger changes need to wait for feature releases so they’re tested thoroughly.
August 19, 2020 at 10:26 am #1409925Simon
Hi Tom,
I’m an idiot! If I read version numbers or your replies I would be dangerous, lol!
So sorry to waste your time not reading properly.
Apologies,
Simon
August 19, 2020 at 1:27 pm #1410118Tom
Lead DeveloperLead DeveloperNo worries at all! Sorry I couldn’t get it into a patch release.
January 21, 2021 at 9:03 am #1628094Arimateia Jr
I’m trying to do the same (give access to “Elements” option for specific users), what is the “final” solution for this, with the current GP version?
January 22, 2021 at 9:46 am #1629596Tom
Lead DeveloperLead DeveloperHi there,
Have you tried the solution above?: https://generatepress.com/forums/topic/add-update-elements-for-specific-user-role/page/3/#post-1403186
January 22, 2021 at 9:48 am #1629601Arimateia Jr
This is what worked for me eventually:
function extend_editor_caps() { // gets the editor role $roleObject = get_role( 'editor' ); if( !$roleObject->has_cap( 'edit_theme_options' ) ) { $roleObject->add_cap( 'edit_theme_options' ); } } add_action( 'admin_init', 'extend_editor_caps'); add_filter( 'generate_elements_admin_menu_capability', function() { return 'edit_posts'; } ); add_filter( 'register_post_type_args', function( $args, $post_type ) { if ( 'gp_elements' === $post_type ) { $args['capability_type'] = 'post'; } return $args; }, 10, 2 ); -
AuthorPosts
- You must be logged in to reply to this topic.