WordPress - remove menu item added by plugin for non-admins - php

How can I remove the following menu item added by a plugin?
admin.php?page=stock-manager

WP Admin Menu Editor Plugin is one of plugins to let you have full control over your wp-admin menu.

This was the answer to my question...
function wpse28782_remove_menu_items() {
if( !current_user_can( 'administrator' ) ):
remove_submenu_page( 'admin.php', 'stock-manager' );
add it to your theme's functions.php

Related

how to remove/hide wordpress menu from admin dashboard

i want to hide wp menu from my admin dashboard..
how remove/hide wordpress menu from admin dashboard .. i was try many code seems not work
I want to hide wpchtmlp_page menu item s. How to remove wpchtmlp_page menu item in admin page?
add_action('admin_menu', 'remove_admin_menu_items', 9999);
remove_menu_page( 'edit.php?post_type=wpchtmlp_page' );
You don't appear to be adding an actual function to the admin_menu hook. With the code you provided, it looks like you're adding a (potentially non-existent?) function to the admin_menu hook, and calling remove_menu_page without being on a hook, so it's firing way before the page is actually added.
add_action( 'admin_menu', 'so_59866103_remove_menu_items', 999 );
function so_59866103_remove_menu_items(){
remove_menu_page( 'edit.php?post_type=wpchtmlp_page' );
}
Generally speaking, you can also use a hook that runs later and before rendering (such as admin_init), which can be especially useful if that menu item was added in an unorthodox way.
add_action( 'admin_init', 'so_59866103_remove_menu_items', 999 );
function so_59866103_remove_menu_items(){
remove_menu_page( 'edit.php?post_type=wpchtmlp_page' );
}
You can remove menu from admin dashboard. Also you can remove any submenu as well. follow the sample code
function remove_item_from_menu() {
remove_menu_page( 'edit.php?post_type=elementor_library' ); // removes elementor addons , menu item added by plugins
remove_menu_page( 'edit-comments.php' ); // removes comment menu
remove_submenu_page('themes.php', 'theme-editor.php'); // remove submenu called theme edititor inside appearance
remove_submenu_page('themes.php', 'widgets.php'); // removes widgets submenu
}
add_action( 'admin_init', 'remove_item_from_menu' );

How to Disable Changing the Installed Theme in Wordpress?

I developed my own WordPress theme for my client!.
If he changes the theme from outside, he will lose my theme.
I want to disable him from changing Wordpress theme from mine theme.
How can I Disable it? is there any way by editing the Wordpress files?
You can remove theme submenu using following code. Add below code in your theme's functions.php file.
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu()
{
remove_submenu_page( 'themes.php', 'themes.php' );
}
Restrict admin to open file
add_action( 'current_screen', 'this_screen' );
function this_screen()
{
$current_screen = get_current_screen();
if( $current_screen ->id === "themes" )
{
wp_die("You don't have access to this page.");
}
}

Is it possible to insert shortcode inside Header menu or top-bar menu in wordpress?

I have made a simple shortcode for my wordpress theme. I'm trying to align it on right-side above the corner of my page. Is it possible to insert shortcode function.php?
I want to place my Short-code in the top-bar (right side above the corner) so that it will work for each pages. Means if i click on any menu then the shortcode should have to work on that menu also.
Actually i'm new in web development. Please suggest me what shall i have to do so it will align where i want and should have work for each module.
You can use wordpress function for that. Please open the file on which you have to place shortcode. Like if you want to place it on header open header.php and add
<?php echo do_shortcode('[your_shortcode]'); ?>
where you want your shortcode content to appear
The best way is to find the top bar menu hook of your theme and then add this code (adapted for your needs) in your function.php child theme :
function my_shotcode_inside_top_bar ( $items, $args ) {
if (is_page() && $args->theme_location == 'secondary') {
$items .= '<li class="my-class">' . do_shortcode( "[my_shortcode]" ) . '</li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'my_shotcode_inside_top_bar', 10, 2 );
is_page displays the shortcode in pages only but you can choose another condition or no condition at all.
secondary is the hook and it depends on your theme. You can normally find it in your theme header.php file.
A menu location selector should be added - that way some themes support multiple menus, and some are called "top" or custom added.
The shortcode could then contain a call to whatever a menu position is:
EG: [myshortcode menu="secondary"]
Didn't have enough points to add this as a comment.

How to remove wordpress admin menu items specific to a user role?

I have a wordpress website with learnpress plugin installed. We have tried all the available user role management plugins to remove admin menu items for a specific role and have managed to remove most of the ones we wanted with plugin "adminimize". However, this plugin does was not able to remove two unwanted admin menu items pointed out in this image http://i.imgur.com/gi5qT2d.jpg
We also tried some functions.php codes to remove menu items but are still not able to find solution. Can someone propose a solution? Thank you.
Have you tried something like this in functions.php in your theme ?
add_action( 'admin_init', 'my_remove_menu_pages' );function my_remove_menu_pages() {
global $user_ID;
if ( current_user_can( 'author' ) ) {
remove_menu_page( 'edit.php' );
remove_menu_page( 'path visible when you hover on the menu' );
remove_menu_page( 'edit.php?post_type=news' ); /*for custom post type*/
}}

Renaming the tabs in Buddypress

I have a multisite WP with Buddypress and BP Multi Network.
The sites are being created automatically (data is coming from external system).
The problem is I want to show only the Activity tab in the menu and I want to rename it as well. I have created bp-custom.php and this is its content:
<?php
function bp_change_tabname() {
global $bp;
$bp->bp_nav['activity']['name'] = 'Duvar';
$bp->bp_nav['members'] = false;
}
add_action( 'bp_setup_nav', 'bp_change_tabname', 999 );
?>
It is not working though. It seems like the content of bp-custom is irrelevant.
Any ideas?
To remove a nav item from the navigation array you can use bp_core_remove_nav_item(). For example:
function my_remove_tabs() {
bp_core_remove_nav_item( $parent_id );
}
add_action( 'bp_setup_nav', 'my_remove_tabs' );
Where $parent_id is the slug of the parent navigation item.
To customise the tab labels, you could use a language file. See the Customising Labels, Messages and URLs article for more info on how and why.

Categories