Hide "Clear" and "Restore Defaults" for editors (Theme Options)
-
Topic
-
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.
Tagged: Theme Options
I am wondering if there is a way to get rid of the “Clear Options” and “Restore Defaults” buttons for non-admins (or possibly for all users – this would be fine as well). I have successfully hidden certain options that I don’t want end users to access (but that I use when I setup a site), while leaving other styling options that I have built for end users. However, I don’t want said end users to be able to clear out all of my settings!
Hello,
I can’t think of any easy way to actually get rid of them because they’re just called within the main function that outputs an options page. However, you could probably just hide them with CSS from your child theme.
You’d just enqueue your own stylesheet into the admin of WordPress:
function my_custom_admin_style() { wp_enqueue_style( 'my_admin_css', get_stylesheet_directory_uri() . '/admin-style.css' ); } add_action( 'admin_enqueue_scripts', 'my_custom_admin_style' );
http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
And then in your admin-style.css, you could just hide them.
#themeblvd_options_page .reset-button, #themeblvd_options_page .clear-button { display: none; }
That is kinda what I was thinking… I’ll give that a shot. Thanks for the quick response!
That worked great. I set it up to only run if the user isn’t an admin, and that also allowed me to hide the content tab (which my non-admins don’t need). This cleaned everything up nicely for the end user, and also keeps them from clearing everything out. Thanks agian!
function yml_custom_admin_style() { if( ! current_user_can( 'edit_users' )) { wp_enqueue_style( 'my_admin_css', get_stylesheet_directory_uri() . '/css/yml-admin-style.css' ); } } add_action( 'admin_enqueue_scripts', 'yml_custom_admin_style' );