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
- Ajax call always returns 0
- Where and how to put inline js in pages
- Hourly Routine Not Firing ( wp_schedule_event() )
- echo or print_r in an admin function
- Displaying a random user with a shortcode
- Assign category using custom field?
- Updating users_can_register option?
- Changing post category from dropdown
- img width and height attributes being set by get_the_post_thumbnail
- How to properly add NPM packages and integrate them in WordPress?
- change in form-checkout.php by using code in functions.php
- Custom function in My Custom Functions returning 403
- Register vendor JS/CSS only on pages that require them?
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- functions.php How to add css/js depending on Template Name?
- Why is my page feed returning empty content?
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Accessing two databases wordpress
- Add a jQuery Function
- How do I change a parent theme’s function through the child theme?
- Enqueue script on every page except one
- Best way to handle lack of titles in microblogging
- Redirect to other page if login
- get_terms (or tax_query) for term of current post?
- 404 when enqueue_script using plugin_url
- WP Customizer API loaded into functions.php
- How to use get_posts() function in functions.php
- How Can I add a menu to the theme from withen the function.php file
- WordPress – using sessions?
- Trigger email alert if file downloaded
- Completely Disable WordPress RSS Feeds
- How to hide content on mobile in the functions.php file – woocommerce
- WordPress Lite/Light
- Selecting specific query for offset
- Is_Page doesnt detect my page
- Show image after X para – center aligned
- Problems adding a new field to product in cart
- Site title not showing. Please help me
- function replace_text for entire page
- Create html from function
- WP supersize not displaying when different languages flags are selected
- wp_list_pages change of children and anchor of parent
- Admin Panel errors because of functions.php
- Using Output from one Function and calling it into another
- How to add a class and title attribute to the link generated by next/previous post
- “Headers already sent” while trying to add a CSS file to my login page?