Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

[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 8 posts - 31 through 38 (of 38 total)
  • Author
    Posts
  • #1403186
    Tom
    Lead Developer
    Lead Developer

    Thanks for the reminder! I’ve added this filter in 1.12.0: generate_elements_metabox_ajax_allow_editors

    So 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!

    #1409040
    Simon

    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

    #1409796
    Tom
    Lead Developer
    Lead Developer

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

    #1409925
    Simon

    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

    #1410118
    Tom
    Lead Developer
    Lead Developer

    No worries at all! Sorry I couldn’t get it into a patch release.

    #1628094
    Arimateia 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?

    #1629596
    Tom
    Lead Developer
    Lead Developer
    #1629601
    Arimateia 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 );
    
Viewing 8 posts - 31 through 38 (of 38 total)
  • You must be logged in to reply to this topic.