• I’m trying to extract or get atleast the user_id upon registration using user_register hook.

    add_action( ‘user_register’, ‘display_id’, 10, 1);

    function display_id( $user_id ) {
    echo ‘<script type=”text/javascript”>alert(“Registration of user <?php echo $user_id; ?> successful”);</script>’;
    }

    But the alert doesn’t even shows up.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    There are many hooks where directly outputting content will never make it to the browser. Generally speaking, you could save the value somewhere, even if in a oft maligned global variable. Then output your content using the global value at a more reliable and controllable point in the page output.

    In the case of user ID, this is usually available through a number of WP functions besides the user_register action. You could likely get results by adding your output via some filter that fires on the page, using something like get_current_user_id() in your filter callback.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting user id or other info through user_register hook’ is closed to new replies.