Tell us what you are trying to do?
I’ve created some Custom Post Types and created editor page Templates for each of them. On the template page associated with each of them I want to hide the Fields & Views, Toolset Forms and Access buttons to all users except administrators. I’d also like to hide certain things in the right hand sidebar of the editor page such as Content Template and Theme Name Settings for all users other than administrators. Is this something that Toolset manages or should I contact the theme authors (WP Astra).
Many thanks,
Barry.
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site? enlace oculto
Hi Barry,
Thank you for contacting us and I'd be happy to assist.
To hide the Toolset buttons ( Fields & Views, Toolset Forms, and Access ) and the content template selection option, for all users except administrators, you can include the following code snippets, in your active theme's "functions.php" file:
function remove_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 non-administrator 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', 'remove_toolset_buttons' );
function remove_content_template_metabox() {
global $WPV_templates;
// only remove "Content Template" metabox for non-administrators
if ( is_admin() && !current_user_can( 'manage_options' ) ) {
remove_action('admin_head', array($WPV_templates,'post_edit_template_options'));
}
}
add_action('admin_menu', 'remove_content_template_metabox');
To hide other options from the post edit screen, you can use WordPress' own "remove_meta_box" function:
https://codex.wordpress.org/Function_Reference/remove_meta_box
For any specific options which are being controlled through the Astra theme, it would be best to consult it's official support team and documentation.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
My issue is resolved now. Thank you!