Skip to main content
added 36 characters in body
Source Link
Chittaranjan
  • 2.5k
  • 23
  • 18

In your case $registered is the user id not the user object. So so it does not work. Please changeuse the function code as given below.

add_action( 'user_register', 'set_user_registration_date', 10, 1 ); function set_user_registration_date( $user_id ) { $user = get_userdata ( $user_id );  // Update the registration meta data update_user_meta ( $user_id, 'registration_date', $user->user_registered ); } 

In your case $registered is the user id not the user object. So it does not work. Please change the function code as below.

add_action( 'user_register', 'set_user_registration_date', 10, 1 ); function set_user_registration_date( $user_id ) { $user = get_userdata ( $user_id ); update_user_meta ( $user_id, 'registration_date', $user->user_registered ); } 

In your case $registered is the user id not the user object so it does not work. Please use the code as given below.

add_action( 'user_register', 'set_user_registration_date', 10, 1 ); function set_user_registration_date( $user_id ) { $user = get_userdata ( $user_id );  // Update the registration meta data update_user_meta ( $user_id, 'registration_date', $user->user_registered ); } 
Source Link
Chittaranjan
  • 2.5k
  • 23
  • 18

In your case $registered is the user id not the user object. So it does not work. Please change the function code as below.

add_action( 'user_register', 'set_user_registration_date', 10, 1 ); function set_user_registration_date( $user_id ) { $user = get_userdata ( $user_id ); update_user_meta ( $user_id, 'registration_date', $user->user_registered ); }