Support » Plugin: WordPress Social Share, Social Login and Social Comments Plugin - Super Socializer » Send woocommerce “new account’ email after new user logs in with facebook

  • Resolved warrior7089

    (@warrior7089)


    Is it possible to send woocommerce “new account’ email to the new user after log in with Facebook using the plugin facebook button?
    Currently the code below in social-login.php sends the default wordpress new user email even if the login occurred on woocommerce login/register form.

    /**
     * Send new user notification email
     */
    function heateor_ss_new_user_notification($userId){
    	global $theChampLoginOptions;
    	$notificationType = '';
    	if(isset($theChampLoginOptions['password_email'])){
    		$notificationType = 'both';
    	}elseif(isset($theChampLoginOptions['new_user_admin_email'])){
    		$notificationType = 'admin';
    	}
    	if($notificationType){
    		wp_new_user_notification($userId, null, $notificationType);
    	}
    }
    • This topic was modified 1 year, 5 months ago by  warrior7089.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Would be happy if plugin devs can add functionality of sending woocommerce emails if user has checked options.
    For example the below code does this, but it’s not perfect and requires merging conflicts after each plugin update:

    function heateor_ss_new_user_notification($userId){
            global $woocommerce;
            if ((isset($theChampLoginOptions['enable_before_wc']) && $theChampLoginOptions['enable_before_wc'] == 1) || (isset($theChampLoginOptions['enable_after_wc']) && $theChampLoginOptions['enable_after_wc'] == 1)) {
                $woocommerce->mailer()->emails['WC_Email_Customer_New_Account']->customer_new_account($userId);
            }
    //	global $theChampLoginOptions;
    //	$notificationType = '';
    //	if(isset($theChampLoginOptions['password_email'])){
    //		$notificationType = 'both';
    //	}elseif(isset($theChampLoginOptions['new_user_admin_email'])){
    //		$notificationType = 'admin';
    //	}
    //	if($notificationType){
    //		wp_new_user_notification($userId, null, $notificationType);
    //	}
    Plugin Contributor Heateor Support

    (@heateor)

    Would be happy if plugin devs can add functionality of sending woocommerce emails if user has checked options.

    We will take care of this in upcoming releases.

    Another option (if WP >= 4.9) is to use the filter wp_new_user_notification_email. (This will use the woocommerce email for all new users which use the default wordpress mail)

    In my case I dont need auto generated passwords, but you can adapt to your specific case.

    public function wp_new_user_notification_email($wp_new_user_notification_email, $user, $blogname) {
    
                if (class_exists('WooCommerce') && $user) {
                    $wc_emails = WC_Emails::instance();
                    $email = $wc_emails->emails['WC_Email_Customer_New_Account'];
                    /* @var $email WC_Email_Customer_New_Account */
    
                    // Set object variables so the email can use it
                    $email->object = $user;
                    $email->user_pass = '';
                    $email->user_login = stripslashes($user->user_login);
                    $email->user_email = stripslashes($user->user_email);
                    $email->recipient = $email->user_email;
                    $email->password_generated = false;
    
                    $wp_new_user_notification_email = array(
                        'to' => $user->user_email,
                        'subject' => $email->get_subject(),
                        'message' => $email->get_content_html(),
                        'headers' => $email->get_headers(),
                    );
                }
                return $wp_new_user_notification_email;
            }
    • This reply was modified 1 year, 5 months ago by  faacsousa.
    Plugin Contributor Heateor Support

    (@heateor)

    @faacsousa Thanks for the input.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Send woocommerce “new account’ email after new user logs in with facebook’ is closed to new replies.