Hide admin notice when user profile updated

You can simply check each of user meta details to see if they are blank or not. The code below is yours with with a check for first and last name. function wpse_user_welcome_notice() { // Make sure that the user is assigned to the subscriber role, specifically. $user = wp_get_current_user(); if ( !in_array( ‘subscriber’, $user->roles … Read more

Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?

WordPress redirects you back to the user-edit.php page upon successful user update, so while the admin_notices has yet been fired in your sulock_save_profile_fields(), the message (your custom admin notice) is never displayed because of the redirection. And one way to fix it, is by filtering the redirect URL via the wp_redirect filter: // In sulock_save_profile_fields() … Read more

register_setting & add_settings_error validation issues with multiple fields

If you want your sanitization callback to apply only to a specific settings field (i.e. a database option registered using register_setting()), then you would want to use a different callback for each of your settings fields. E.g. // Sample field HTML: //<input name=”field-1″ value=”<?php esc_attr( get_option( ‘field-1’ ) ); ?>”> function my_settings_field_1_validation( $value ) { … Read more

How to create Admin Notice from Plugin with argument? [duplicate]

This would be an good use PHP 5.3+ anonymous functions. Closure example: <?php function Twit_the_url( $post_ID ) { //connect to twitter api //send tweet with url //get twitter response //send response to admin notice : add_action(‘admin_notices’, function() use ($httpstatus) { echo ‘<div class=”error”><p>’, esc_html($httpstatus), ‘</p></div>’; }); return $post_ID; } add_action( ‘publish_post’, ‘Twit_the_url’); Alternatively, you could … Read more

Displaying “One Time” Notification in Plugins

The idea is that you need to save_errors or update the option that has the errors/notices whenever you want. As soon as its output once by admin_notices it will be cleared. /** * Sample_Notice_Handling */ class Sample_Notice_Handling { public static $_notices = array(); /** * Constructor */ public function __construct() { add_action( ‘admin_notices’, array( $this, … Read more

Show message from backend

The problem is that when a post is saved, there’s a redirect back to the edit post page and the admin_notices action never runs. This means that any admin notice you put on any of the save post actions (save_post, transition_post_status, etc.) will be thrown away (since they’re not persistent) during that redirect. The workaround … Read more

Getting admin notices to appear after page refresh

You should use set_transient this is stored and will show up after the page reloads as it is like cookies on the server side. function SITE_profile_update_notice() { // Add this to your code where you want to the transient to fire after function set_transient( ‘fx-admin-notice-panel’, true, 5 ); } /* Add admin notice */ add_action( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)