Wordpress Admin delete update-nag for user - php

I want to hide/delete the update notification of WordPress v4.9.1 from administration panel.

You can add this to your functions.php.
function hide_update_nag_admin()
{
if (current_user_can('update_core')) {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
add_action( 'admin_notices', 'hide_update_nag_admin', 1 );
The function checks to see if the current user has permission to update the core, if they do, then remove the update nag from the admin. We then add the hook into the admin_notices function.
Here's some reading about admin_notices:
https://digwp.com/2016/05/wordpress-admin-notices/
And a similar question:
https://wordpress.stackexchange.com/questions/231010/remove-update-nags-for-non-admins
And a plugin to do it:
https://wordpress.org/plugins/no-update-nag/

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' );

remove_action() not working in Woocommerce

i'm trying to change the order of my product page in woocommerce but i have a few problems with the remove_action().
I activated the child theme and in my functions.php i'm tryin to remove the add-to-cart button to add it back on another position.
I tried to put my remove_action() into a function that gets executed right after my parent theme loads.
function change_order() {
add_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 15 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 30 );
}
add_action( 'after_setup_theme', 'change_order' );
The add_action gets excuted but the remove_action() isn't working...
I tried the same with 'init' instead of 'after_setup_theme' but it is still not working...
Does anybody know a solution for my problem ?
Use a different single product hook
add_action('woocommerce_single_product_summary','change_order' );
function change_order() {
add_action('woocommerce_product_meta_end','woocommerce_template_single_add_to_cart', 15 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 30 );
}
Works and tested.

Stop user role changing only when canceling a subscription

I'm using WooCommerce Subscriptions plugin and I would like to stop user role changing only when canceling a subscription.
I found a code snippet here:
add_filter( 'woocommerce_subscriptions_update_users_role', '__return_false', 100 );
… which Stop WooCommerce Subscriptions Changing a User's Role. This will stop role changing when purchasing a subscription too.
What I would like is to stop user role changing only when canceling a subscription.
Is it possible?
Thanks
You could try to use woocommerce_subscription_status_cancelled action hook (without any guaranty as it's untested), this way:
add_action( 'woocommerce_subscription_status_cancelled', 'keep_user_role_unchanged_on_cancelled_status' );
function keep_user_role_unchanged_on_cancelled_status(){
add_filter( 'woocommerce_subscriptions_update_users_role', '__return_false', 100 );
}
The Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Reference: Subscription Status Change Actions
remove_action( 'woocommerce_subscription_status_cancelled', 'wcs_maybe_make_user_inactive_for', 10, 1 );
Use this in your active theme functions.php

Wordpress: How to add a post request after the user confirmed the email and activated the account?

Respecting all the wp pattern, security and update.
Maybe there is already a plugin than do this action.. I could not find any.
I see there is an hook USER_REGISTRATION_COMPLETE that I could use, I would like to know what's the general approch to edit wp code. Shall I create my own plugin?
Thanks
You can use this in functions.php file in your theme
add_action( 'user_register', 'action_after_user_register', 10, 1 );
function action_after_user_register( $user_id ) {
//Do Some Things
}
I had success with this function when link to Odoo system.

Is there any way to hide all admin notification for non admin users in wordpress?

Is there any way to all hide admin notification for non-admin users.
I have used below code but it will hide only update notification but I need to hide all notification
function hide_update_notice_to_all_but_admin_users()
{
if (!current_user_can('update_core')) {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );
I'm also want to hide these type of notifications.
Try to insert the following code on your functions.php file of your active theme. This code may disable all the updates notifications regarding plugins, themes & WordPress completely.
function remove_core_updates(){
global $wp_version;
return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
I hope that this code works fine.

Categories