• Resolved afranaila

    (@afranaila)


    Hi Jeff thanks for the good plugin. Currently I’m using the latest version 6.4.1

    I’m having problem with the email activation after user registration. I created a registration using admin-ajax and I want to trigger the email activation to send to the user. I use email moderation module.

    below is my ajax handler code

    `$userid = wp_insert_user($newUser);

    if($userid){
    do_action( ‘tml_new_user_registered’, $userid, $password, 11 );

    wp_send_json( array(
    “success” => true,
    “message” => “send activation email”
    ));

    }else{
    wp_send_json( array(
    “success” => false,
    “message” => “something went wrong”
    ));
    }

    The tml_new_user_registered is work but it sends New User email not the User Activation email

    Any idea ?

    Thanks

    https://wordpress.org/plugins/theme-my-login/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter afranaila

    (@afranaila)

    I also tried using this hook

    do_action( 'tml_user_activation_resend', $userid);

    but still have no luck 🙁

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Try this instead:

    do_action( 'tml_new_user_registered', $userid, null, 'both' );

    Thread Starter afranaila

    (@afranaila)

    Hi Jeff,

    Thanks for your reply, I tried just now this hook

    do_action( 'tml_new_user_registered', $userid, null, 'both' );

    But still doesnt work, I only get New User Email for reset password, but no Welcome Email (User Activation)

    I didnt use any, custom redirect and use the custom email template with these variables:

    User Activation: Activation Link: %activateurl%

    New User: Reset URL: %reseturl%

    Cheers,

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Which moderation mode is selected?

    Thread Starter afranaila

    (@afranaila)

    E-mail Confirmation

    Thanks,

    Plugin Author Jeff Farthing

    (@jfarthing84)

    How are you registering the user?

    Thread Starter afranaila

    (@afranaila)

    Hi Jeff, Thanks again. I registering the user like a subscribe, I choose E-mail only setting in TML General setting, and I request it using admin-ajax

    this is my form

    <form class="subscribe single">
         <div class="input-group">
            <input type="email" name="user_email" class="form-control" placeholder="Your business email address">
            <span class="input-group-btn">
    	      <button type="submit" class="btn btn-default pink btnSubscribe">Get Started!</button>
    	      <?php wp_nonce_field( 'post_nonce', 'post_nonce_field' ); ?>
    	      <input type="hidden" name="action" value="doRegister">
             </span>
    	 <span class="fa fa-times-circle" data-toggle="tooltip" data-placement="top" title=""></span><span class="fa fa-check-circle"></span>
         </div>
    </form>

    and this is my ajax handler

    $email = $_POST['user_email'];
    
          if(!is_email($email)){
    	   wp_send_json( array(
      		"success" => false,
      		"message" => "<strong>Ooops!</strong> It seems your email is not valid!."
      	   ));
          }
    
          if( email_exists( $email )) {
    	   wp_send_json( array(
                    "success" => false,
                    "message" => "<strong>Ooops!</strong> Email address already exist!"
               ));
          }
    
    	   $password = wp_generate_password(12, true, false);
    
    	   $newUser = array(
                   'user_pass' =>  $password,
                   'user_login' => $email,
                   'user_email' => $email,
                   'role' => 'pending'
               );
    
               $userid = wp_insert_user($newUser);
    
               if ( ! is_wp_error( $userid ) ) {
    	       do_action( 'tml_new_user_registered', $userid, null , 'both');
    
    		wp_send_json( array(
                       "success" => true,
                       "message" => "We’ve sent you an activation email. Please check your email and activate your account."
                    ));
    
    	   }else{
    		wp_send_json( array(
                       "success" => false,
                       "message" => "<strong>Sorry!</strong> We are having problem creating your account. Please try again later!"
                    ));
    	   }
    Plugin Author Jeff Farthing

    (@jfarthing84)

    Actually, as of 6.4.2, tml_new_user_registered is gone. Try this:

    do_action( 'register_post' );
    do_action( 'register_new_user', $userid );

    Also, don’t set the role when you create the user, or the email isn’t sent. TML will set the role when the register_new_user action is called.

    Thread Starter afranaila

    (@afranaila)

    Hi Jeff Thanks for your reply,

    Yeah it works now, when user register, it sent the Welcome email using User Activation template

    User Activation: Activation Link: %activateurl%

    but once user activated, it didnt send the email using New User template

    New User: Reset URL: %reseturl%

    it sent WP regular New User Registration email and WP Your username and password info Email instead

    Cheers,

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Ah, that would be a bug with 6.4.2. Since I changed the the action that applies the new user email filters to register_post, it no longer gets applied when a user activates or gets approved, because that action isn’t fired.

    Looks like a 6.4.3 will be incoming…

    Thread Starter afranaila

    (@afranaila)

    Hi Jeff,

    I have updated with the new version 6.4.3 and IT WORKS!!!

    Thank you so much for your great plugin and support jeff

    Cheers,

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

The topic ‘How to trigger Email Activation’ is closed to new replies.