- This topic has 37 replies, 3 voices, and was last updated 3 years, 2 months ago by Arimateia Jr.
-
AuthorPosts
-
September 25, 2019 at 12:37 am #1018334Michael
this is what i did:
https://generatepress.com/forums/topic/add-update-elements-for-specific-user-role/#post-997004π
September 25, 2019 at 9:54 am #1018835TomLead DeveloperLead DeveloperStrange. Is it only the menu item that isn’t working? Does going to
edit.php?post_type=gp_elements
work for you?September 25, 2019 at 11:19 pm #1019281Michaelyes, when i have the ‘register_post_type_args’ filter activated, i can access the page. when i activate the show in menu filter, it doesnt work. unless i remove the first filter and then i can see it in the menu but when i go to the page i have a permission issue. is it working on your side? thank you
September 26, 2019 at 9:41 am #1019839TomLead DeveloperLead DeveloperAh, I think I see why. Editors aren’t allowed in the “Appearance” tab. We can tell them it’s ok to be in Elements, but it doesn’t matter, as they’re not allowed in the parent section (Appearance).
I wonder if it would be worth creating a new role/capability for these users so they can see the Appearance tab?
September 27, 2019 at 12:01 am #1020167Michaeli think that would complicate GP and is a bad idea.
my opinion is that Elements contain content and are more than just “appearances” and could be moved to the main menu
as an editor, i cannot modify the header and footer and theme options. but i am allowed to modify all the different pages and posts and custom post types.
Hero Elements are parts of the pages themselves.
The first hero element that i created contains a H1 on the homepage… an editor should be able to modify that. Same for hooks, they can show up anywhere in pages. And layouts control pages as well.π
September 27, 2019 at 12:07 am #1020170Michaelwhen you think of it, gp_elements is a custom post type and in my experience, custom post types always show up in the main menu with posts pages and so on. what was the idea behind that decision to put it in “appareances”? π
September 27, 2019 at 9:20 am #1020613TomLead DeveloperLead DeveloperI find the admin menu very polluted these days with people adding all of their top-level links, so I do everything I can not to add to that.
You can tell Elements to show up in the top-level with a simple function:
add_filter( 'register_post_type_args', function( $args, $post_type ) { if ( 'gp_elements' === $post_type ) { $args['show_in_menu'] = true; } return $args; }, 10, 2 );
Let me know if that does it or not π
September 30, 2019 at 12:55 am #1022275Michaeli totally understand what you are saying and experienced it myself.
my personal opinion:
– when you develop a website, your main focus is the theme and it’s functionalities and they are important, thus own a place in the main menu. and surely a page builder like elementor owns its place in the main menu as well.
– all the editors won t have access to important content like h1 on homepage… this doesnt make sense and go against what an editor is.it s not because plugin creator have poor judgment that you need to hide yourself in the appearance menu.
thank you
September 30, 2019 at 10:06 am #1022715TomLead DeveloperLead DeveloperI agree – I’ll see if I can find a solution that works for everyone π
October 1, 2019 at 1:11 am #1023079Michaelgreat, thanks π
July 1, 2020 at 1:08 pm #1348748SimonHi Tom,
So I was looking to do something similar and give an Editor role access to Elements. I’ve looked extensively through this thread and employed the following code:
/* 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 );
The issue I am facing is that when the Editor creates a new Hook using GP Elements and they choose the Display Rules, they cannot select a specific Page or Post. When they choose either of these options, the second select field does not appear to choose “All Pages” or “All Posts” or even specific pages/posts on the website.
Using the code above means an Editor also cannot edit someone else’s Elements which is actually fine as I ideally don’t want them to be able to do that anyway.
Kind regards,
Simon
July 1, 2020 at 2:33 pm #1348806TomLead DeveloperLead DeveloperAh yea, we use
current_user_can( 'manage_options' )
when running the AJAX to get the posts for security purposes.I’ll see if this is something we can adjust to allow editors as well.
July 2, 2020 at 12:38 am #1349071SimonHi Tom,
Thanks for replying so quickly, I think I read something similar to what you mentioned in this other Support Forum thread.
I 100% understand the need for security purposes as well. I don’t really want to comment out the code as described in that Support Forum thread. Both for security reasons but also I would have to change the code each time the plugin updated.
However, in the interim, as I need this to work now for a client without giving them too much access to the site ( although I release with Elements access they could do a lot of damage ). I have changed the following line of code in the class-metabox.php line 1832-1834:
if ( ! current_user_can( 'manage_options' ) ) { return; }
to:
if ( ! current_user_can( 'edit_posts' ) ) { return; }
Aside from the Editor now being able to potentially wield hell with hooks and code in the header of the site, I assume there is nothing wrong with the code change in the plugin I made ( I understand I will have to keep updated the plugin code unless we are able to get an alternative solution ).
Kind regards,
Simon
July 2, 2020 at 9:37 am #1349715TomLead DeveloperLead DeveloperDefinitely nothing wrong with that. I’ll look at adding a filter to make it possible to choose between
manage_options
andedit_posts
.August 14, 2020 at 8:23 am #1402839SimonHi Tom,
I’ve added a note in my internal systems to update this code after each update, although it has moved now, lol! (But I found it). Is creating a filter for this possible in a future update?
Sorry to ask about this again.
Apologies,
Simon
-
AuthorPosts
- You must be logged in to reply to this topic.