• Hi All, I am trying to write simple function that automatically gives all new users a certain default value for a meta-key in the usermeta table on sign up (register) using get_current_user_id() and update_user_meta(). Does anyone know what function goes in the add_action hook? Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey achanne,

    just use this action hook, tested it, works well.
    “testmeta” is the meta key. “Value to save” is the value you want to save. 😉

    add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
    
    function myplugin_registration_save( $user_id ) {
    
        update_user_meta($user_id, 'testmeta', 'Value to save');
    
    }

    Source

    Thread Starter achanne

    (@achanne)

    Thanks-you!!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Function To Run on New User Sign Up’ is closed to new replies.