• Resolved hayhow

    (@hayhow)


    Hi Ultimate Member Team,

    Congratulations on a great plugin, it’s a really great piece of work.

    I am using a code snippet to auto approve users that are made in the users admin screen as detailed here:

    https://docs.ultimatemember.com/article/1650-auto-approve-a-user-on-registration-in-wp-admin

    It works nicely except calling UM()->user()->approve() triggers the Welcome email to be sent twice. All other emails such as Account Deleted only trigger once as normal.

    Steps taken to resolve so far:
    1. I’ve RETURNED FALSE using numerous WP core filters/functions to disable notifications such as wp_new_user_notification().
    2. Swapped to TwentyTwentyTwo theme, issue remains.
    3. Ensured no other membership style plugins are active.

    I was wondering maybe because I’ve manually called UM()->user()->approve() does that mean that there’s a UM core filter that I need to remove using remove_filter which is triggering the second email ?

    WP version: 5.9.3
    UM version: 2.4.1

    Any advice or thoughts at this point would be gratefully received!

    Many thanks,

    Dave Hayhow

    • This topic was modified 3 years, 12 months ago by hayhow.
    • This topic was modified 3 years, 12 months ago by hayhow.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @hayhow

    Thanks for contacting our support.

    Could you please try the following code?

    UM()->user()->approve();
     // Disable Welcome Email
     remove_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );

    The above code should be triggered before this line:

    add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );
    

    If the above doesn’t work, please try this one:

    UM()->user()->approve();
    add_filter("um_get_option_filter__welcome_email_on", "__return_false");

    Hope this helps you

    Thread Starter hayhow

    (@hayhow)

    Hey UM Team,

    Thanks for your quick reply.

    Brilliant. Solved straight away by removing the um_post_registration_approved_hook action.

    I set the priority of my function to 5 to ensure it runs before um_post_registration_approved_hook.

    My final snippet looks like this:

    
    // Auto approve a user on creation in WP Admin
    add_action('um_registration_complete','um_approve_admin_created_user_automatically', 5, 2);
    function um_approve_admin_created_user_automatically( $user_id ){
    
        if( is_admin() ){
            um_fetch_user( $user_id );
    		UM()->user()->approve();
            remove_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );
    
    	}
    }
    

    Thank you so much for your support.

    Kind regards,

    Dave Hayhow

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @hayhow

    Thanks for letting us know.

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

The topic ‘Duplicate Welcome Emails’ is closed to new replies.