Put the add_action
line inside the if (!current_user_can('activate_plugins') ) {
:
<?php
/************ Remove admin menu items from anyone who isn't an admin ************/
if (!current_user_can('activate_plugins') ) {
function my_remove_menu_pages() {
remove_menu_page('link-manager.php');
remove_menu_page('tools.php');
remove_menu_page('edit-comments.php');
}
add_action( 'admin_menu', 'my_remove_menu_pages' );
};
?>
Related Posts:
- wp_enqueue_script was called incorrectly
- Remove type attribute from script and style tags added by WordPress
- Displaying the number of updates available in the Admin area
- Remove a menu item created by a plugin
- How to remove Customize from admin menu bar after WP 4.3
- Modify Admin Bar Link
- Run functions only in the admin area?
- How to display error messages using WP_Error class?
- difference between add_object_page and add_menu_page
- Print Dashboard menu name and link
- Functions.php reverted to new one
- Why is my Gutenberg block returning an error after initial save?
- Debugging with functions.php
- Logout hyperlink within a sub-menu
- Add Featured image column into wordpress admin on pages AND posts
- Change position of media in admin menu
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- Warning: : DOMDocument::loadHTML(): Empty string supplied as input in functions.php when adding classes to post images
- Parse error after modifying the template menu [closed]
- Creating A New Admin Menu Tab For Theme Options
- help I changed one currency in woocommerce and everything is ruined [closed]
- Need help getting a function to function
- Connecting to a 2nd DB gives me no results when querying
- debugging errors.. how to remedy?
- Functions Error: Impacting Galleries
- Strange error from functions.php files (wp_register_script)
- Show errormessages on wrong username/password on custom loginform?
- Problems with functions.php! Error! [closed]
- How to change a specific admin label
- Looking for Functions File that doesn’t Exist
- functions.php pharse error on complete new install
- “Conditional query tags do not work before the query is run. Before > then, they always return false. “
- How to add publish/draft button in Admin Post Lists
- Which method is more correct for removing WooCommerce Extensions menu item?
- MCAPI.class.php showing some error
- I’m getting invalid taxonomy in init action
- Translation Function missing text-domain [closed]
- Hide certain post types from editors
- What is wrong with functions.php? Fills error log with same error
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- add_role menu pages are not visible
- Random text changing to weird icons in both admin & front end
- jQuery HoverIntent is not a function
- create submenu page – error function not found or invalid function name
- Why does modifying my functions.php file always result in a server error
- Function Reference for custom link in Admin Menu Management Page
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Woocommerce – Checkout error message
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- Comment turned Invisible
- Logout redirect via page template without confirmation?
- Convert Image to Webp on upload without plugin
- warning: trying to access array offset on value of type bool ACF field image group
- Remove or disable Appearance > Patterns
- Rewrite standard $errors messages output via function.php
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- Changing Admin Menu Labels
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Passing arguments to a admin menu page callback?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- How to load parent_theme functions.php before child_theme?
- How to load scripts/styles specific for a page
- Programatically add options to “add new” custom field dropdown
- Is there any global functions.php file which works for any theme?
- Excluding iPad from wp_is_mobile
- When should you, and when should you not, use wp_list_pluck()?
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Difference between the_permalink() and get_permalink() function
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Child theme – Overriding ‘require_once’ in functions.php