I'm trying to show a modal dialog when user get registered (action_hook: user_register) using the woocommerce plugin, but without having any result.

I would appreciate any help!

The code is shown below.


// handler for new_user_registered
$myplugin->register_action_hook (


public static function add_new_user ($userid)
    function enqueue_scripts() {
        wp_enqueue_script('modaljs', plugin_dir_url(__FILE__) . 'js/modal.js', array('jquery'));
        wp_enqueue_style('modalcss', plugin_dir_url(__FILE__) . 'css/modal.css');
    add_action('wp_enqueue_scripts', 'enqueue_scripts');
    <button id="myBtn">Open Modal</button>
    <div id="myModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
            <span class="close">&times;</span>
            <div class="modal-body">
            <div class="modal-footer">

What I am getting as a result is this image My image

Thank you in advance for any suggestion!

  • the action user_register is thrown when the user is created on a POST request and not on a page display. on which page do you want to display this modal dialog ?
    – mmm
    Commented Jan 30, 2018 at 9:22
  • I would like to display a modal after the user is successfully registered.
    – fmp
    Commented Jan 30, 2018 at 9:30

1 Answer 1


Like mmm said, user_register() is not for displaying additional content, but for hooking into the internal user creation flow.

What you will need to do is to hook into user_register() to store a short-lived transient marking that the user has registered. Then, add your modal code to the wp_footer() output, wrapped in a test for the transient you just set to see if a new user has been created (not forgetting to delete the transient immediately afterwards).

Hope that helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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