Exemplo n.º 1
0
if (email_exists($order->billing_email)) {
    if ($options['debug'] == 'yes') {
        $log->add('marginalen', 'Billing email: ' . $order->billing_email);
    }
    $user = get_user_by('email', $order->billing_email);
    if ($options['debug'] == 'yes') {
        $log->add('marginalen', 'Customer User ID: ' . $user->ID);
    }
    $customer_id = $user->ID;
    update_post_meta($order_id, '_customer_user', $customer_id);
} else {
    // Create new user
    if ($options['create_customer_account'] == 'yes') {
        $password = wp_generate_password();
        $password_generated = true;
        $new_customer = create_new_customer($order->billing_email, $order->billing_email, $password, $order->billing_first_name);
        // Check if creation of new customer was successfull
        if (is_wp_error($new_customer)) {
            //Failed
            $order->add_order_note(sprintf(__('Customer creation failed. Error: %s.', 'marginalen'), $new_customer->get_error_message(), $order_id));
            $customer_id = 0;
        } else {
            // Creation succeess
            $order->add_order_note(sprintf(__('New customer created (user ID %s).', 'marginalen'), $new_customer, $order_id));
            // Send New account creation email to customer?
            if ($options['send_new_account_email'] == 'yes') {
                $new_customer_data = apply_filters('woocommerce_new_customer_data', array('user_login' => $email, 'user_pass' => $password, 'user_email' => $email, 'role' => 'customer'));
                do_action('woocommerce_created_customer', $new_customer, $new_customer_data, $password_generated);
            }
        }
        update_post_meta($order_id, '_customer_user', $customer_id);
Exemplo n.º 2
0
                $subscribe_checkbox_ok = 0;
            }
        } else {
            $subscribe_checkbox_ok = 0;
        }
        // Evaluate all oks
        if ($submission_valid == 1 && $name_first_ok == 1 && $name_last_ok == 1 && $birth_day_ok === true && $birth_month_ok === true && $birth_year_ok === true && $phone_ok == 1 && $email_ok == 1 && $password1_ok == 1 && $password2_ok == 1 && $captcha_ok === true && $agree_checkbox_ok == 1) {
            // Prep for database using mysqli_real_escape_string()
            $name_first = database_prep($name_first);
            $name_last = database_prep($name_last);
            $phone = database_prep($phone);
            $email = database_prep($email);
            $hashed_password = password_hash($password1, PASSWORD_BCRYPT);
            $hashed_con_number = password_hash(mt_rand(), PASSWORD_BCRYPT);
            $hashed_con_number = substr($hashed_con_number, 7);
            create_new_customer($name_first, $name_last, 0, 0, 0, $phone, $hashed_password, $email, $hashed_con_number, $subscribe_checkbox_ok);
            send_confirmation_email($name_first, $name_last, $email, $hashed_con_number);
            if (isset($_POST)) {
                unset($_POST);
            }
            include "_connections/connection_close.php";
            $location = 'confirm_email.php?action=new&email=' . $email;
            redirect($location);
        }
    } else {
        echo "Submission error!";
        exit;
    }
}
// end if $_POST submit is set
if (isset($_POST)) {