WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to reset admin's meta value after login. It can be changed after login by admin via control panel, but I want to reset it after every login.

I used this code but it's not working:

function reset_dismiss_message(){
    update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice', false );
add_action('wp_login', 'reset_dismiss_message');

I checked if and found it that the get_current_user_id() function is not returning user's ID as there is no data generated when wp_login action processing.

So how can I do this?

share|improve this question
up vote 1 down vote accepted

wp_login action passes 2 arguments $user_login and $user. The second argument is the object of WP_User class, which you can use to get user id from:

function reset_dismiss_message( $user_login, $user ) {
    update_user_meta( $user->ID, 'tgmpa_dismissed_notice', false );
add_action( 'wp_login', 'reset_dismiss_message', 10, 2 );
share|improve this answer
This works perfectly. Thanks..!! – Bimal Rekhadiya Mar 6 '13 at 15:03

Instead you might want to try;

function reset_dismiss_message(){
    global $current_user;
    update_user_meta( $current_user->ID, 'tgmpa_dismissed_notice', false );
add_action('wp_login', 'reset_dismiss_message');
share|improve this answer
don't mix up wp_login function with wp_login action ;) – Eugene Manuilov Mar 6 '13 at 10:06
@EugeneManuilov I thought as much... was just going by vague memory. Removed, thanks. – userabuser Mar 6 '13 at 10:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.