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
- Remove or disable Appearance > Patterns
- Rewrite standard $errors messages output via function.php
- How to use the do_action () with parameter
- TinyMCE custom styles remove class when switching styles
- Extending the site search to include a single custom field
- Notify users whenever a new post is published based on their preference
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- syntax for remove_filter in parent theme with class
- Remove Header and Footer in iframe
- How to Acheive the custom woocommerce category template
- Can I remove the Rich Text box editor for a specific post?
- CSS stylesheet not loading
- How To Get WordPress Categories Link List?
- Generate permalinks
- Best Practice for Syncing Local Development With Staging Development [closed]
- How can I create a page with a specific URL?
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- How does this function get the id of the most recent post?
- Batch update menu_order attribute alphabetically
- Automatically wrap multiple images in div
- Ajax not working properly
- create shortcode to list users with specific meta key value
- How to add ‘data-caption’ inside an anchor tag
- How can I get my Script to work on the Login page?
- Search filter by Post title OR Meta Title Value [duplicate]
- Why is functions.php file in child not initializing and over-writing parent?
- shortcode help require
- echo custom fields with AJAX
- How to create a functions.php in child theme? [closed]
- wordpress get_post_meta give only first value
- Using multiple line variable inside a function?
- Determine if, within a post, you are on page 2 or greater – WordPress documentation circular
- Wp-query Order By problem
- Protect get_query_var from manual input in url
- Shortcode to get featured image of specific id post
- wp_get_archives() output
- Problem with WordPress output text (‘esc_html’ & ‘wp_richedit_pre’)
- Get slug of current category in functions.php
- Prevent wp_signon redirect on failed login for ajax login
- removing description tabs – single product page – breaks footer
- OOP Switch statement with array as parameter
- How to add a cron job in my functions.php
- Pagination won’t work on custom page
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Trying to Add a LEFT Sidebar?
- Login functions
- Highlight only current on single pages
- How do I add schema markup to individual WordPress posts without using plugins?