Skip Navigation

[Gelöst] Hide Template Layout selection for non Admin

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
How to Hide or remove Template Layout selection for non Admin
Solution:
To remove Toolset buttons you need to add custom code to your current theme's functions.php file.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/hide-template-layout-selection-for-non-admin/#post-614589

Relevant Documentation:

This support ticket is created vor 6 Jahre, 1 Monat. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 Antworten, has 2 Stimmen.

Last updated by Cesar vor 6 Jahre.

Assisted by: Minesh.

Author
Artikel
#614399
Captura de pantalla 2018-02-08 a las 18.43.23.png

Hi,

I need to hide the Template Layout box for non Admin.
When doing so using regular WP Screen options the template layout box is always visible. Is totally useless information for an author or editor and is not translated

Is that the supposed behavior? or am I missing somethinh

Thanks

#614402
Captura de pantalla 2018-02-08 a las 18.46.46.png

The same for Types and Access short codes, Content Layout Editor is not even something that an Author can use, they are not allowed by default within the plugin
Can I get ride of them for non Admin users?

Thanks

#614589

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to remove Toolset buttons you need to add following code to your current theme's functions.php file:

function func_remove_unwanted_toolset_buttons(){
 
    // only remove buttons on back end for non-administrators
    if ( is_admin() && !current_user_can( 'manage_options' ) ) {
 
        // remove the Fields and Views button
        add_filter( 'toolset_editor_add_form_buttons', '__return_false' );
    
        // remove the CRED button
        add_filter( 'toolset_cred_button_before_print', '__return_false' );

      
    
        // remove the Access button for all roles 
        add_filter( 'toolset_editor_add_access_button', function(){
 
            global $wp_roles;
            $all_roles = array_keys($wp_roles->roles);
  
            return $all_roles;
        } );


    }
}
add_action( 'init', 'func_remove_unwanted_toolset_buttons' );

To hide "Content Layout Editor" button:

1) add following code to your current theme's functions.php file:

add_action( 'admin_init', 'my_admin_init' );
function my_admin_init() {
if(!current_user_can('manage_links')) {
   
 
      wp_enqueue_style( 'myStylesheet', get_stylesheet_directory_uri() . '/myStylesheet.css' );
}
}

2) create a css file "rm-content-layout-editor.css", put it in your theme root folder.with following code:

div.wp-media-buttons a.js-layout-private-add-new-top
{
display:none !important;
}

To remove Template Layout box for non Admin.

add_action( 'admin_head', 'wpv_custom_admin_head', 20);
function wpv_custom_admin_head() {


    remove_meta_box( 'wpddl_template', array("your-post-type-slug"), 'side' ); // replace book with your CPT slug

}

Where:
Replace "your-post-type-slug" with your post type slug for which you want to hide the "Template Layout" box.

More info:
=> http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table

#620850

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Here is more details about WordPess standard function: remove_meta_box

More info:
https://codex.wordpress.org/Function_Reference/remove_meta_box

You can mark this resolved as well 🙂

#620851
Captura de pantalla 2018-03-01 a las 10.45.47.png
Captura de pantalla 2018-03-01 a las 10.46.08.png

Yes I will 😉

But I need to bother you just a little more

How can I hide the Toolset shortcode on the top admin bar and the <if> shortcode from the text box?
Please 🙂
Thanks

#620854

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I'm happy to help you with your new question as well and I'm here to help you But may I kindly ask you to open a new ticket for your each new question.

This will help other users searching on the forum. Thank you for understanding.

Even you can create a new ticket and assign it to me.

#620861

Sorry, considering is the same question I thought this should be the place to ask

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.