• Resolved robertshippey

    (@robertshippey)


    Hey,

    How can I give a non-admin user the ability to edit the headers/footers with elementor.

    As far as I can see from the code the only capability checked is edit_posts which I’ve checked is part of the users capabilities (currently Editor role) but I get the following error message: “Sorry, you are not allowed to access this page.”

    Please let me know if it is possible to grant a capability to non-admins which would allow them to edit the headers/footers. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Nikhil Chavan

    (@nikschavan)

    Hello @robertshippey,

    This is because of the post type sets show_in_menu to false and the header footer posts are accessed form a different menu under Appearance

    You can use this snippet to change this –

    function your_prefix_filter_post_type_args_hfe( $args, $name ) {
    
    	// bail if post-type is not from hfe.
    	if ( 'elementor-hf' !== $name ) {
    		return $args;
    	}
    
    	if ( ! current_user_can( 'administrator' ) ) {
    		$args[ 'show_in_menu' ] = true;
    	}
    
    	return $args;
    }
    
    add_filter( 'register_post_type_args', 'your_prefix_filter_post_type_args_hfe', 20, 2 );

    Here is a tutorial that you can follow on adding custom PHP code on your site – https://wpastra.com/docs/add-custom-php-code/

    Thread Starter robertshippey

    (@robertshippey)

    Hi @nikschavan,

    This is perfect, thanks! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘User capabilities’ is closed to new replies.