• Resolved makmerghen

    (@makmerghen)


    hello dear
    as per your instruction I used this code to let the logged in user can add new users while he logged in
    add_filter( 'um_registration_for_loggedin_users', '__return_true' );

    and I used this code to avoid the auto sign out of the current user and the auto sign in of the new registered user

    add_action("init","um_062921_prevent_user_login");
    function um_062921_prevent_user_login(){
        if( is_user_logged_in() ){
            remove_action( 'um_registration_complete', 'um_check_user_status', 100, 2 );
            remove_action( 'um_user_login', 'um_user_login', 10 );
        }
    }

    it works but the second code lead to stopping of the emails that should be sent after registration to the new user and to admin, it didn’t sent at all

    so please advise how to avoid that
    best regards

    • This topic was modified 3 years, 5 months ago by makmerghen.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @makmerghen

    Try adding this code snippet below to enable the Email notifications for client and administrators:

    add_action("um_registration_complete","um_070221_email_notification",1);
    function um_070221_email_notification( $user_id ){
        um_fetch_user( $user_id );
        $email = um_user("user_email");
        UM()->mail()->send( $email, 'welcome_email' );
        
        $emails = um_multi_admin_email();
    	if ( ! empty( $emails ) ) {
    		foreach ( $emails as $email ) {
                UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
            }
        }
        
    }

    Regards,

    Thread Starter makmerghen

    (@makmerghen)

    thank you very much
    I tried the code and results are:-
    1- sending welcome email to the new user is work
    but
    2- no email was sent to admin I double check that the new user notification mail is active and the email is right

    so please advise

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @makmerghen

    Can you try this one?

    add_action("um_registration_complete","um_070221_email_notification",1);
    function um_070221_email_notification( $user_id ){
        um_fetch_user( $user_id );
        $email = um_user("user_email");
        UM()->mail()->send( $email, 'welcome_email' );
        
        $emails = um_multi_admin_email();
    	if ( ! empty( $emails ) ) {
    		foreach ( $emails as $email ) {
    			if ( um_user( 'account_status' ) != 'pending' ) {
    				UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
    			} else {
    				UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
    			}
    		}
    	}
        
    }
    Thread Starter makmerghen

    (@makmerghen)

    thank you for the code
    unfortunately it gave the same results :-
    1- sending welcome email to the new user is work
    but
    2- no email was sent to admin

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @makmerghen

    Let’s try dumping the Admin emails and see if there are values in it.

    Please test these code snippets to check the Admin emails:

    add_action("um_registration_complete","um_070221_email_notification",1);
    function um_070221_email_notification( $user_id ){
        
        $emails = um_multi_admin_email();
        var_dump( $emails );
        wp_die('UM Test');
    }

    Now try registering a test user and see if there are admin emails that will be displayed.

    Regards,

    Thread Starter makmerghen

    (@makmerghen)

    thanks you
    I add the snippets and I got this message when trying to save it
    The snippet has been deactivated due to an error on line 3:
    Cannot redeclare function um_070221_email_notification.

    after that I registered new user using the frontend registration form and same result
    new user email sent
    admin email didn’t send
    regards

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @makmerghen

    Could you please try this one to dump the admin emails?

    add_action("um_registration_complete","um_070221_dump_email_notification",1);
    function um_070221_dump_email_notification( $user_id ){
        
        $emails = um_multi_admin_email();
        var_dump( $emails );
        wp_die('UM Test');
    }

    Send me the dumped data after the registration so we can review them.

    Regards,

    Thread Starter makmerghen

    (@makmerghen)

    will create new installation and redo every step again and will let you know results

    • This reply was modified 3 years, 4 months ago by makmerghen.
    Thread Starter makmerghen

    (@makmerghen)

    1- I installed fresh copy of wordpress and installed only UM and code snippets
    2- I add the snippets that was provided by you for:_
    a- add new user by logged in user
    b- avoid new user to take session in stead of the logged in user
    c- show successfully message after registration
    d- prevent UM form from drag current user data into the registration form
    e- send reset password link after registration

    add_action("um_registration_complete","um_051121_generate_pass_reset_registration", 1, 2 );
    function um_051121_generate_pass_reset_registration( $user_id, $args ){
    
        um_fetch_user( $user_id );
        UM()->user()->password_reset();
    
    }

    f- to fix send no emails after registration

    add_action("um_registration_complete","um_070221_email_notification",1);
    function um_070221_email_notification( $user_id ){
        um_fetch_user( $user_id );
        $email = um_user("user_email");
        UM()->mail()->send( $email, 'welcome_email' );
        
        $emails = um_multi_admin_email();
    	if ( ! empty( $emails ) ) {
    		foreach ( $emails as $email ) {
    			if ( um_user( 'account_status' ) != 'pending' ) {
    				UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
    			} else {
    				UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
    			}
    		}
    	}
        
    }

    the result was all works except the next issues
    1- admin email was sent 2 time in stead of 1
    2- send reset password link after registration was not sent

    so please advise
    and if possible please send me email to send you the credential of site to let you see the issue life if that better
    warm regards

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @makmerghen

    1. Please try this to fix the issue with the duplicate Admin email:

    add_action("um_registration_complete","um_070221_email_notification",1);
    function um_070221_email_notification( $user_id ){
        if( ! is_user_logged_in() ) return;
    
        um_fetch_user( $user_id );
        $email = um_user("user_email");
        UM()->mail()->send( $email, 'welcome_email' );
        
        $emails = um_multi_admin_email();
    	if ( ! empty( $emails ) ) {
    		foreach ( $emails as $email ) {
    			if ( um_user( 'account_status' ) != 'pending' ) {
    				UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
    			} else {
    				UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
    			}
    		}
    	}
        
    }

    2. I tried the following code and it works on my end. Could you please check if the Password Reset notification is enabled in the UM Email settings?

    add_action("um_registration_complete","um_051121_generate_pass_reset_registration", 1, 2 );
    function um_051121_generate_pass_reset_registration( $user_id, $args ){
        um_fetch_user( $user_id );
        UM()->user()->password_reset();
    }

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter makmerghen

    (@makmerghen)

    hello dear
    now both not working
    https://www.mediafire.com/file/lee3sy2q1kqbcid/snippets.json/file
    this an export of all snippets that related to this issue
    please import these snippets may be when work together you can recognize the issue

    best regards

    • This reply was modified 3 years, 4 months ago by Yui.
    • This reply was modified 3 years, 4 months ago by Yui. Reason: email and admin offer removed
    Thread Starter makmerghen

    (@makmerghen)

    I updated to the new version and issue still also
    so please advise

    Thread Starter makmerghen

    (@makmerghen)

    @champsupertramp please I need answer

    Plugin Contributor Champ Camba

    (@champsupertramp)

    I’m closing this thread as there’s a duplicate topic created by the original poster.

    https://www.ads-software.com/support/topic/issue-when-using-specific-filter-and-action/

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Email stopped in this case’ is closed to new replies.