Saltar navegación

[Resuelto] Disabling Fields & Views, Toolset Forms and Access buttons to some users

This support ticket is created hace 5 años, 1 mes. 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por barryG-4 hace 5 años, 1 mes.

Asistido por: Waqar.

Autor
Mensajes
#1379257
Screenshot 2019-11-09 at 14.05.51.png

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

#1379647

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

#1380263

My issue is resolved now. Thank you!