Exemplo n.º 1
0
// If the user is trying to get their code resent
$email = $_POST['email'];
if (isset($email)) {
    $user = get_user_by('email', $email);
    if ($user) {
        // Get the nexmo code from metadata
        $nexmo_code = get_user_meta($user->ID, 'nexmo_code', true);
        if ($nexmo_code) {
            $phone = get_user_meta($user->ID, 'phone', true);
            $country_code = get_user_meta($user->ID, 'country_code', true);
            $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
            try {
                $numberProto = $phoneUtil->parse($phone, $country_code);
                // Send them the nexmo mobile validation
                $phone = $phoneUtil->format($numberProto, \libphonenumber\PhoneNumberFormat::E164);
                send_nexmo_code($phone, $user_id, $nexmo_code);
            } catch (\libphonenumber\NumberParseException $e) {
                //var_dump($e);
            }
        } else {
            $text = "Mobile number is already verified";
        }
    } else {
        $text = "Invalid Email Address";
    }
}
get_header();
?>

<div class="clearfix"></div>
Exemplo n.º 2
0
/**
 * For trial members, send them a nexmo verification code after they checkout
 */
function send_nexmo_to_trial_members($user_id)
{
    if (isset($_REQUEST['first_name'])) {
        $first_name = $_REQUEST['first_name'];
        $last_name = $_REQUEST['last_name'];
        $country = $_REQUEST['country'];
        $state = $_REQUEST['state'];
        $city = $_REQUEST['city'];
        $address = $_REQUEST['address'];
        $zipcode = $_REQUEST['zipcode'];
        $phone = $_REQUEST['phone'];
        $country_code = $_REQUEST['country_code'];
    } elseif (isset($_SESSION['first_name'])) {
        //maybe in sessions?
        $first_name = $_SESSION['first_name'];
        $last_name = $_SESSION['last_name'];
        $country = $_SESSION['country'];
        $state = $_SESSION['state'];
        $city = $_SESSION['city'];
        $address = $_SESSION['address'];
        $zipcode = $_SESSION['zipcode'];
        $phone = $_SESSION['phone'];
        $country_code = $_SESSION['country_code'];
        //unset
        unset($_SESSION['first_name']);
        unset($_SESSION['last_name']);
        unset($_SESSION['country']);
        unset($_SESSION['state']);
        unset($_SESSION['city']);
        unset($_SESSION['address']);
        unset($_SESSION['zipcode']);
        unset($_SESSION['phone']);
        unset($_SESSION['country_code']);
    }
    if (isset($first_name)) {
        update_user_meta($user_id, "first_name", $first_name);
    }
    if (isset($last_name)) {
        update_user_meta($user_id, "last_name", $last_name);
    }
    if (isset($country)) {
        update_user_meta($user_id, "country", $country);
    }
    if (isset($state)) {
        update_user_meta($user_id, "state", $state);
    }
    if (isset($city)) {
        update_user_meta($user_id, "city", $city);
    }
    if (isset($address)) {
        update_user_meta($user_id, "address", $address);
    }
    if (isset($zipcode)) {
        update_user_meta($user_id, "zipcode", $zipcode);
    }
    if (isset($phone)) {
        $country_code = strtoupper($country_code);
        $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
        try {
            $numberProto = $phoneUtil->parse($phone, $country_code);
            $phone = $phoneUtil->format($numberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);
            update_user_meta($user_id, "phone", $phone);
            update_user_meta($user_id, "phone_original", $phone);
            update_user_meta($user_id, "country_code", $country_code);
            // If this user is a trial member
            if (pmpro_hasMembershipLevel('1', $user_id)) {
                // Logout the user
                wp_clear_auth_cookie();
                // Send them the nexmo mobile validation
                $formatted_phone = $phoneUtil->format($numberProto, \libphonenumber\PhoneNumberFormat::E164);
                send_nexmo_code($formatted_phone, $user_id);
            }
        } catch (\libphonenumber\NumberParseException $e) {
            //var_dump($e);
        }
    }
}