[Support request] Add/update Elements for specific user role

Home Forums Support [Support request] Add/update Elements for specific user role

Home Forums Support Add/update Elements for specific user role

Viewing 15 posts - 16 through 30 (of 38 total)
  • Author
    Posts
  • #1018334
    Michael
    #1018835
    Tom
    Lead Developer
    Lead Developer

    Strange. Is it only the menu item that isn’t working? Does going to edit.php?post_type=gp_elements work for you?

    #1019281
    Michael

    yes, 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

    #1019839
    Tom
    Lead Developer
    Lead Developer

    Ah, 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?

    #1020167
    Michael

    i 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.

    πŸ™‚

    #1020170
    Michael

    when 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”? πŸ™‚

    #1020613
    Tom
    Lead Developer
    Lead Developer

    I 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 πŸ™‚

    #1022275
    Michael

    i 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

    #1022715
    Tom
    Lead Developer
    Lead Developer

    I agree – I’ll see if I can find a solution that works for everyone πŸ™‚

    #1023079
    Michael

    great, thanks πŸ™‚

    #1348748
    Simon

    Hi 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

    #1348806
    Tom
    Lead Developer
    Lead Developer

    Ah 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.

    #1349071
    Simon

    Hi 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

    #1349715
    Tom
    Lead Developer
    Lead Developer

    Definitely nothing wrong with that. I’ll look at adding a filter to make it possible to choose between manage_options and edit_posts.

    #1402839
    Simon

    Hi 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

Viewing 15 posts - 16 through 30 (of 38 total)
  • You must be logged in to reply to this topic.