• Resolved delaitec

    (@delaitec)


    Hi, I hope you be well!

    01 – When registering using the Woocommerce My Account page, the user does not receive the initial instructions email.

    This email is only sent when registering using the standard WordPress registration screen (wp-admin / wp-login)

    02 – When Registering using the social network with the Heator Social Login plugin, the instruction email is also not sent.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @delaitec,

    Thanks for contacting us,

    I hope you are doing well, We have to check this and we will keep you updated on this.

    Thanks & Regards

    WP Experts Support Team

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @delaitec,

    We have checked and it is working fine but if the New User Approve does not shoot any email on your side then it may be a problem with your Mail Server.

    Let us know if you have any issues.

    Thank you

    Thread Starter delaitec

    (@delaitec)

    are you sure you tested the registration, and on the my account page?

    only on this combination the email is not send.

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @delaitec,

    Thanks for pointing out these issues. We have fixed these issues. Kindly paste that code snippet into the functions.php file of the child theme.

    Here is the code:

    // 01 – User welcome/instruction email when registering from Woocommerce My Account page
    add_action( 'woocommerce_created_customer', 'nua_woo_user_welcome_email' );
    
    function nua_woo_user_welcome_email($customer_id) {
    
    	$user_info = get_userdata( $customer_id );
        $user_email = $user_info->user_email;
    	nua_welcome_email($user_email);
    
    }
    
    // 02 - User welcome/instruction email when Registering using the social network with the Heator Social Login
    add_action('heateor_sl_user_successfully_created', 'nua_welcome_email_heatero_social', '' , 3);
    
    function nua_welcome_email_heatero_social($user_id, $user_data, $profile_data) {
    
    	$user_email = $user_data['user_email'];
    	nua_welcome_email($user_email);
    }
    
    function nua_welcome_email( $user_email) {
    
    	$message = nua_default_registeration_welcome_email();
    	$message = apply_filters( 'new_user_approve_welcome_user_message', $message, $user_email );
    	$subject = sprintf( __( 'Your registration is pending for approval - [%s]', 'new-user-approve' ), get_option( 'blogname' ) );
    	$subject = apply_filters( 'new_user_approve_welcome_user_subject', $subject );
    	
    	wp_mail(
    	$user_email,
    	$subject,
    	$message,
    	nua_email_message_headers()
      );
    }
    
    function nua_email_message_headers(){
    	$admin_email = get_option( 'admin_email' );
    	if ( isset($_SERVER['SERVER_NAME']) && empty($admin_email) ) {
    		$admin_email = 'support@' . sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME']));
    	}
    	$from_name = get_option( 'blogname' );
    	$headers = array( "From: \"{$from_name}\" <{$admin_email}>\n" );
    	$headers = apply_filters( 'new_user_approve_email_header', $headers );
    	return $headers;
    }

    Please check this and let me know if you still have any issues.

    Thank you

    Thread Starter delaitec

    (@delaitec)

    Hello @hamza1010

    Thank you very much, worked perfectly.

    Using the code you provided, the NUA instruction email is now sent upon registration via the My Account page, and Heateor Social Login.

    I still have some doubts, can you answer me?

    01 – I will always have to use this code to send these emails,
    or will you release a plugin update with this fix built in?

    02 – How do I adjust this welcome email? I would like to word it more clearly for my customers.

    03 – Regarding the “message” displayed after registration:
    The filter (new_user_approve_registration_message) is not changing the default message displayed on the My Account Page after registration, it would be nice if it changed this message when the NUA plugin is active.

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @delaitec,

    01 – I will always have to use this code to send these emails,
    or will you release a plugin update with this fix built in?

    Yes, we will fix it, in the upcoming NUA version.

    02 –?How do I adjust this welcome email? I would like to word it more clearly for my customers.

    Please add this filter for adjusting the welcome email.

    apply_filters( 'new_user_approve_welcome_user_message', $message, $user_email )

    03 –?Regarding the “message” displayed after registration:
    The filter (new_user_approve_registration_message) is not changing the default message displayed on the?My Account Page?after registration, it would be nice if it changed this message when the NUA plugin is active.

    Please use this code which will display the NUA default messages on the My Account Page when a user registers.

    if ( class_exists('pw_new_user_approve') ) {
    
    	add_action('woocommerce_created_customer', 'woo_user_created', 10, 2);
    	add_filter( 'woocommerce_add_success', 'woo_add_custom_registration_notice', 99, 1 );
    
    }
    
    function woo_user_created($user_id, $user_data) {
    	$user_status = get_user_meta($user_id, 'pw_user_status', true);
    	$user_data = array('user_id'=>$user_id, 'user_status'=>$user_status);
    	set_transient( 'nua_new_user_status', $user_data, 0.5 * HOUR_IN_SECONDS );
    	
    }
    function woo_add_custom_registration_notice( $notice_message ) {
    	
    	if( strpos( $notice_message, 'Your account was created successfully' ) !== false ) {
    		
    		if( get_transient('nua_new_user_status')['user_status'] =='approved' ) {
    			$customer_id = $user_transient = get_transient('nua_new_user_status')['user_id'];
    			delete_transient( 'nua_new_user_status' );
    			$customer = new WC_Customer( $customer_id );
    			$user_email = $customer->get_email();
    			$username = $customer->get_username();
    			$notice_message = nua_default_approve_user_message();
    			$notice_message = nua_do_email_tags( $notice_message, array(
    				'context'    => 'approve_user',
                	'user'       => $username,
                	'user_login' => $user_email,
                	'user_email' => $username,
    			) );
    			return $notice_message;
    		}
    		else if( get_transient('nua_new_user_status')['user_status'] =='pending' ) {
    
    			delete_transient( 'nua_new_user_status' );
    			$notice_message = nua_default_registration_complete_message();
    			return $notice_message;
    
    		}
    	return $notice_message;
    	}
    }

    Thank you

    Thread Starter delaitec

    (@delaitec)

    Hello.

    Thank you very much for your help, I was now able to send the personalized welcome email both to users who create their accounts through the my account page, as well as through the heator social login.

    I will make my code available so that other users can use it:

    //>>> Email sent to the USER after registering a new user on the My Account page or through Heateor Social Login.
    // Required for this email to be sent correctly.
    //> Settings when registering through the Woocommerce My Account page.
    function nua_woo_user_welcome_email($customer_id) {
    $user_info = get_userdata( $customer_id );
    $user_email = $user_info->user_email;
    nua_welcome_email($user_email);
    }
    add_action('woocommerce_created_customer', 'nua_woo_user_welcome_email');
    //> Settings when registering via Heateor Social Login.
    function nua_welcome_email_heatero_social($user_id, $user_data, $profile_data) {
    $user_email = $user_data['user_email'];
    nua_welcome_email($user_email);
    }
    add_action('heateor_sl_user_successfully_created', 'nua_welcome_email_heatero_social', '' , 3);
    //> Configuring the sending of the email.
    function nua_welcome_email( $user_email) {
    $message = nua_default_registeration_welcome_email();
    $message = apply_filters( 'new_user_approve_welcome_user_message', $message, $user_email );
    $subject = sprintf( __( 'Your registration is pending for approval - [%s]', 'new-user-approve' ), get_option( 'blogname' ) );
    $subject = apply_filters( 'new_user_approve_welcome_user_subject', $subject );
    wp_mail(
    $user_email,
    $subject,
    $message,
    nua_email_message_headers()
    );
    }
    //> Configuring header.
    function nua_email_message_headers() {
    $admin_email = get_option( 'admin_email' );
    if ( isset($_SERVER['SERVER_NAME']) && empty($admin_email) ) {
    $admin_email = 'support@' . sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME']));
    }
    $from_name = get_option( 'blogname' );
    $headers = array( "From: \"{$from_name}\" <{$admin_email}>\n" );
    $headers = apply_filters( 'new_user_approve_email_header', $headers );
    return $headers;
    }
    //> Email content.
    add_filter('new_user_approve_welcome_user_subject',function(){
    //subject
    return 'Registration under review';
    });
    add_filter('new_user_approve_welcome_user_message',function(){
    //body
    $current_user = wp_get_current_user();
    return 'Hello, Your registration request has been received and you are now on our waiting list!
    Once your registration is approved you will receive an email informing you. '.get_bloginfo("name");
    });

    An observation,
    I tried to add HTML code in the message and it didn’t work.

    It was something very simple like:
    <b>Title</b>

    I also tried , <strong> and others, but none worked.

    Do you know how i can do this?

    Below is the code that I tested without success:


    //> Email content.
    add_filter('new_user_approve_welcome_user_subject',function(){
    //subject
    return 'Registration under review';
    });
    add_filter('new_user_approve_welcome_user_message',function(){
    //body
    $current_user = wp_get_current_user();
    return '<b>Hello</b>,
    Your registration request has been received and you are now on our waiting list!
    Once your registration is approved you will receive an email informing you.
    '.get_bloginfo("name");
    });

    Thanks for every help

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @delaitec,

    We have to check this and we will keep you updated on this.

    Thank you

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @delaitec,

    You should use this code before email content filters.

    add_filter( 'wp_mail_content_type', 'nua_html_content_type' );
     
     function nua_html_content_type( $content_type ) {
    	$content_type = 'text/html';
    
    	return $content_type;
    }
    

    Please check it and let me know if you still have any issues.

    Thank you

    Thread Starter delaitec

    (@delaitec)

    Thanks.
    Now I can create emails using HTML markup.

    Plugin Support Mirza Hamza

    (@hamza1010)

    Thanks for the feedback.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Woocommerce Registered User Does Not Receive Email Instructions’ is closed to new replies.