Ejemplo n.º 1
0
function alimir_bootModal_ajax_registration()
{
    check_ajax_referer('ajax-form-nonce', 'security2');
    $user_login = $_POST['user_login'];
    $user_email = $_POST['user_email'];
    $register_captcha = '';
    if (isset($_POST['register_captcha'])) {
        $register_captcha = $_POST['register_captcha'];
    }
    if ($user_login == null || $user_email == null || (get_option('enable_register_captcha') == 1 and $register_captcha == null)) {
        echo json_encode(array('registered' => false, 'message' => __('<p class="alert alert-info" data-alert="alert">Please fill all the fields.</p>', 'alimir')));
    } else {
        if (get_option('enable_register_captcha') == 1 and !strCmp(strToUpper($_SESSION['register_captcha']), strToUpper($register_captcha)) == 0) {
            echo json_encode(array('registered' => false, 'message' => __('<p class="alert alert-error" data-alert="alert">captcha invalid.</p>', 'alimir')));
        } else {
            $errors = register_new_user($user_login, $user_email);
            if (is_wp_error($errors)) {
                $registration_error_messages = $errors->errors;
                $display_errors = '<div class="alert alert-error" data-alert="alert">';
                foreach ($registration_error_messages as $error) {
                    $display_errors .= '<div>' . $error[0] . '</div>';
                }
                $display_errors .= '</div>';
                echo json_encode(array('registered' => false, 'message' => $display_errors));
            } else {
                echo json_encode(array('registered' => true, 'message' => __('<p class="alert alert-success" data-alert="alert">Registration complete. Please check your e-mail.</p>', 'alimir')));
            }
        }
    }
    die;
}
Ejemplo n.º 2
0
function wiziapp_user_registration()
{
    if (!empty($_POST)) {
        $_REQUEST['action'] = '';
        $username = $_REQUEST['user_login'];
        $email = $_REQUEST['user_email'];
        ob_start();
        require_once ABSPATH . 'wp-includes/registration.php';
        require_once ABSPATH . 'wp-login.php';
        ob_end_clean();
        $GLOBALS['WiziappLog']->write('info', 'Before register user: '******'account.wiziapp_user_registration');
        $user_id = register_new_user($username, $email);
        $GLOBALS['WiziappLog']->write('info', 'After register user: '******'account.wiziapp_user_registration');
        if (is_int($user_id)) {
            //            $status = TRUE;
            $result = __('Registration successfull', 'wiziapp');
        } else {
            $result = implode('<br>', $user_id->get_error_messages());
            //            $status = FALSE;
        }
    } else {
        $result = '';
    }
    //    $header = array(
    //        'action' => 'register',
    //        'status' => $status,
    //        'code' => ($status) ? 200 : 4004,
    //        'message' => ($status) ? '' : 'Invalid registartion',
    //    );
    //    echo json_encode(array_merge(array('header' => $header), $result));
    //    exit;
    return $result;
}
 /**
  * Checks post data and registers user
  * @return string
  */
 function register()
 {
     if (!empty($_REQUEST['register_ajax_widget'])) {
         $return = array();
         if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_REQUEST['user_login']) && !empty($_REQUEST['user_email'])) {
             //require_once( ABSPATH . WPINC . '/registration.php');
             // todo - recaptcha
             $errors = register_new_user($_POST['user_login'], $_POST['user_email']);
             if (!is_wp_error($errors)) {
                 //Success
                 // do they have an envato id?
                 if (isset($_REQUEST['envato_purchase_code']) && !empty($_REQUEST['envato_purchase_code'])) {
                     // add this based on tc plugin.
                 }
                 $user_data = get_userdata($errors);
                 $return['result'] = true;
                 $return['message'] = __(sprintf('Thank you %s. Registration is complete. Please check your e-mail.', $user_data->user_login));
             } else {
                 //Something's wrong
                 $return['result'] = false;
                 $return['error'] = $errors->get_error_message() . "<br>Username: "******"/^jQuery[_a-zA-Z0-9]+\$/", $_REQUEST['callback'])) {
             $return = $_GET['callback'] . "({$return})";
         }
         echo $return;
         exit;
     }
 }
Ejemplo n.º 4
0
function px_verify_view_registration_page()
{
    global $errors;
    $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
    if ($http_post) {
        $action = $_POST['wp-submit'];
        $code = esc_attr($_POST['purchase_code']);
        $verify = px_verify_purchase($code);
        if ($action == 'Register') {
            if (!is_wp_error($verify)) {
                $user_login = $_POST['user_login'];
                $user_email = $_POST['user_email'];
                $errors = register_new_user($user_login, $user_email);
                if (!is_wp_error($errors)) {
                    $user_id = $errors;
                    $pxarr1 = px_verify_globals(1);
                    $pxarr2 = px_verify_globals(2);
                    $pxarr2 = array_keys($pxarr2);
                    if ($verify['px_envato_item'] == $pxarr1['item1']) {
                        wp_update_user(array('ID' => $user_id, 'role' => $pxarr2[0]));
                    } else {
                        if ($verify['px_envato_item'] == $pxarr1['item2']) {
                            wp_update_user(array('ID' => $user_id, 'role' => $pxarr2[1]));
                        } else {
                            wp_update_user(array('ID' => $user_id, 'role' => 'bbp_blocked'));
                        }
                    }
                    do_action('px_verifier_user_registration', $user_id, $verify);
                    update_user_meta($user_id, 'px_envato_username', $verify['px_envato_username']);
                    update_user_meta($user_id, 'px_envato_purchase_date', $verify['px_envato_purchase_date']);
                    update_user_meta($user_id, 'px_envato_purchase_code', $verify['px_envato_purchase_code']);
                    update_user_meta($user_id, 'px_envato_license', $verify['px_envato_license']);
                    update_user_meta($user_id, 'px_envato_item', $verify['px_envato_item']);
                    update_user_meta($user_id, 'px_envato_support_amount', $verify['px_envato_support_amount']);
                    update_user_meta($user_id, 'px_envato_support_until', $verify['px_envato_support_until']);
                    $redirect_to = 'wp-login.php?checkemail=registered';
                    wp_safe_redirect($redirect_to);
                    exit;
                } else {
                    px_verify_view_registration_form($errors, $verify);
                }
            } else {
                px_verify_view_verification_form($verify);
            }
        } elseif ($action == 'Verify') {
            if (!is_wp_error($verify)) {
                px_verify_view_registration_form($errors, $verify);
            } else {
                px_verify_view_verification_form($verify);
            }
        }
    } else {
        px_verify_view_verification_form();
    }
    px_verify_custom_style();
    exit;
}
Ejemplo n.º 5
0
function px_verify_view_registration_page()
{
    global $errors;
    $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
    if ($http_post) {
        $action = $_POST['wp-submit'];
        $code = esc_attr($_POST['purchase_code']);
        $verify = px_verify_purchase($code);
        if ($action == 'Register') {
            if (!is_wp_error($verify)) {
                $user_login = $_POST['user_login'];
                $user_email = $_POST['user_email'];
                $errors = register_new_user($user_login, $user_email);
                if (!is_wp_error($errors)) {
                    $user_id = $errors;
                    if ($verify['px_envato_item'] == 'WordPress Blog Android App') {
                        wp_update_user(array('ID' => $user_id, 'role' => 'px_wpba_customer'));
                    } else {
                        if ($verify['px_envato_item'] == 'WP Google Cloud Messaging') {
                            wp_update_user(array('ID' => $user_id, 'role' => 'px_wpgcm_customer'));
                        } else {
                            wp_update_user(array('ID' => $user_id, 'role' => 'participant'));
                        }
                    }
                    update_user_meta($user_id, 'px_envato_username', $verify['px_envato_username']);
                    update_user_meta($user_id, 'px_envato_purchase_date', $verify['px_envato_purchase_date']);
                    update_user_meta($user_id, 'px_envato_purchase_code', $verify['px_envato_purchase_code']);
                    update_user_meta($user_id, 'px_envato_license', $verify['px_envato_license']);
                    update_user_meta($user_id, 'px_envato_item', $verify['px_envato_item']);
                    update_user_meta($user_id, 'px_envato_support_amount', $verify['px_envato_support_amount']);
                    update_user_meta($user_id, 'px_envato_support_until', $verify['px_envato_support_until']);
                    $redirect_to = 'wp-login.php?checkemail=registered';
                    wp_safe_redirect($redirect_to);
                    exit;
                } else {
                    px_verify_view_registration_form($errors, $verify);
                }
            } else {
                px_verify_view_verification_form($verify);
            }
        } elseif ($action == 'Verify') {
            if (!is_wp_error($verify)) {
                px_verify_view_registration_form($errors, $verify);
            } else {
                px_verify_view_verification_form($verify);
            }
        }
    } else {
        px_verify_view_verification_form();
    }
    px_verify_custom_style();
    exit;
}
 /**
  * Checks post data and registers user
  * @return string
  */
 function register()
 {
     if (!empty($_REQUEST['register_ajax_widget'])) {
         $return = array();
         //			$return['result'] = false;
         //			$return['error'] = "Forum registration temporarily closed, please try again later";
         if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_REQUEST['user_login']) && !empty($_REQUEST['user_email'])) {
             //require_once( ABSPATH . WPINC . '/registration.php');
             // check purchase code.
             $valid_purchase_codes = false;
             if (!isset($return['result']) && get_option('_bbps_envato_username', '') && get_option('_bbps_envato_api_key', '')) {
                 $purchase_code = isset($_REQUEST['user_purchase_code']) ? strtolower(trim($_REQUEST['user_purchase_code'])) : false;
                 if (strlen($purchase_code) > 10) {
                     $api_result = verify_purchase($purchase_code);
                     if (is_array($api_result)) {
                         $valid_purchase_codes = array();
                         $valid_purchase_codes[$purchase_code] = $api_result;
                     }
                 }
                 if (!$valid_purchase_codes) {
                     $return['result'] = false;
                     $return['error'] = "Incorrect Item Purchase code, please make sure it is copied correctly.";
                 }
             }
             if (!isset($return['result']) && get_option('_bbps_recaptcha_client', '') && get_option('_bbps_recaptcha_secret', '')) {
                 // recaptcha time!
                 $ch = curl_init("https://www.google.com/recaptcha/api/siteverify");
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($ch, CURLOPT_HEADER, false);
                 curl_setopt($ch, CURLOPT_POST, true);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, array("secret" => get_option('_bbps_recaptcha_secret', ''), "response" => isset($_REQUEST['g-recaptcha-response']) ? $_REQUEST['g-recaptcha-response'] : false, 'remoteip' => $_SERVER['REMOTE_ADDR']));
                 $data = curl_exec($ch);
                 $google_result = @json_decode($data, true);
                 if (!$google_result || !$google_result['success']) {
                     $return['result'] = false;
                     $return['message'] = var_export($google_result, true);
                 }
             }
             if (!isset($return['result'])) {
                 $errors = register_new_user($_POST['user_login'], $_POST['user_email']);
                 if (!is_wp_error($errors)) {
                     //Success
                     $user_data = get_userdata($errors);
                     if (is_array($valid_purchase_codes) && count($valid_purchase_codes)) {
                         update_user_meta($user_data->ID, 'envato_codes', $valid_purchase_codes);
                     }
                     $return['result'] = true;
                     $return['message'] = __(sprintf('Thank you %s. Registration is complete. Please check your e-mail.', $user_data->user_login));
                 } else {
                     //Something's wrong
                     $return['result'] = false;
                     $return['error'] = $errors->get_error_message() . "<br>Username: "******"/^jQuery[_a-zA-Z0-9]+\$/", $_REQUEST['callback'])) {
             $return = $_GET['callback'] . "({$return})";
         }
         echo $return;
         exit;
     }
 }
Ejemplo n.º 7
0
<?php

$error_mes = "";
if (isset($_POST["new_name"]) and isset($_POST["new_pass1"]) and isset($_POST["new_pass2"])) {
    if (!preg_match('/^[0-9A-Za-z]{8,256}+$/', $_POST["new_pass1"])) {
        $error_mes = '<div class="alert alert-danger" role="alert">Password must be 8-256 char long, contain numbers, big or small letters!</div>';
    } else {
        if ($_POST["new_pass1"] === $_POST["new_pass2"]) {
            $return_string = register_new_user($_POST["new_name"], $_POST['email'], $_POST["new_pass1"]);
            if ($return_string === 0) {
                $error_mes = '<div class="alert alert-danger" role="alert">name in use!</div>';
            } elseif ($return_string === 1) {
                $error_mes = '<div class="alert alert-danger" role="alert">problem!</div>';
            } elseif ($return_string === 2) {
                $error_mes = '<div class="alert alert-success" role="alert">Registration complete! You can now <a href="index.php?page=login">login!</a></div>';
            } else {
                $error_mes = "other problem!";
            }
        } else {
            $error_mes = '<div class="alert alert-danger" role="alert">Passwords do not match!</div>';
        }
    }
}
?>


  <div class="container">
      <h1>Register</h1>
      <p>Register now, and keep track of your courses</p>
      <p>As no actual identification data is provided, please use unique password for this site!</p>
      <p><?php 
Ejemplo n.º 8
0
 /**
  * Checks post data and registers user, then exits
  * @return string
  */
 public static function register()
 {
     $return = array();
     if (get_option('users_can_register')) {
         $errors = register_new_user($_REQUEST['user_login'], $_REQUEST['user_email']);
         if (!is_wp_error($errors)) {
             //Success
             $return['result'] = true;
             $return['message'] = __('Registration complete. Please check your e-mail.', 'login-with-ajax');
             //add user to blog if multisite
             if (is_multisite()) {
                 add_user_to_blog(get_current_blog_id(), $errors, get_option('default_role'));
             }
         } else {
             //Something's wrong
             $return['result'] = false;
             $return['error'] = $errors->get_error_message();
         }
         $return['action'] = 'register';
     } else {
         $return['result'] = false;
         $return['error'] = __('Registration has been disabled.', 'login-with-ajax');
     }
     return $return;
 }
 function test_multiple_accounts_via_register_new_user_that_exceed_limit()
 {
     $this->set_option(array('account_limit' => 3, 'allow_for_everyone' => true));
     $users = array();
     for ($i = 0; $i < 3; $i++) {
         $users[] = register_new_user("user{$i}", '*****@*****.**');
     }
     $this->assertFalse(is_wp_error($users[0]));
     $this->assertFalse(is_wp_error($users[1]));
     $this->assertTrue(is_wp_error($users[2]));
     $this->assertEquals(array('exceeded_limit'), $users[2]->get_error_codes());
 }
Ejemplo n.º 10
0
     exit;
 }
 if (!get_option('users_can_register')) {
     wp_redirect(site_url('wp-login.php?registration=disabled'));
     exit;
 }
 $user_login = '';
 $user_email = '';
 $display_name = '';
 $phone_number = '';
 if ($http_post) {
     $user_login = $_POST['user_login'];
     $user_email = $_POST['user_email'];
     $display_name = $_POST['display_name'];
     $phone_number = $_POST['phone_number'];
     $errors = register_new_user($user_login, $user_email, $display_name, $phone_number);
     if (!is_wp_error($errors)) {
         $redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
         wp_safe_redirect($redirect_to);
         exit;
     }
 }
 $registration_redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
 /**
  * Filter the registration redirect URL.
  *
  * @since 3.0.0
  *
  * @param string $registration_redirect The redirect destination URL.
  */
 $redirect_to = apply_filters('registration_redirect', $registration_redirect);
Ejemplo n.º 11
0
 public function save($updateOnly = false)
 {
     // Allow an exception to be thrown.
     try {
         // If user is made a Super Admin group and user is NOT a Super Admin
         //
         // @todo ACL - this needs to be acl checked
         //
         $my = MFactory::getUser();
         //are we creating a new user
         $isNew = empty($this->id);
         // If we aren't allowed to create new users return
         if ($isNew && $updateOnly) {
             return true;
         }
         // Get the old user
         $oldUser = new MUser($this->id);
         // Fire the onUserBeforeSave event.
         MPluginHelper::importPlugin('user');
         $dispatcher = MDispatcher::getInstance();
         $result = $dispatcher->trigger('onUserBeforeSave', array($oldUser->getProperties(), $isNew, $this->getProperties()));
         if (in_array(false, $result, true)) {
             // Plugin will have to raise its own error or throw an exception.
             return false;
         }
         //////////////////////////////////////
         //todo:: update old user
         //////////////////////////////////////
         register_new_user($this->username, $this->email);
         // Fire the onUserAfterSave event
         $dispatcher->trigger('onUserAfterSave', array($this->getProperties(), $isNew, $result, $this->getError()));
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     return $result;
 }
Ejemplo n.º 12
0
/**
 * Signup a new user
 *
 * @package WP Idea Stream
 * @subpackage users/functions
 *
 * @since 2.1.0
 *
 * @param bool $exit whether to exit or not
 * @uses check_admin_referer()
 * @uses wp_idea_stream_get_redirect_url()
 * @uses wp_idea_stream_add_message()
 * @uses WP_Error()
 * @uses register_new_user()
 * @uses wp_update_user()
 * @uses wp_safe_redirect();
 * @uses apply_filters() Calls 'wp_idea_stream_users_is_signup_field_required' to force a contact method to be required
 *                       Calls 'wp_idea_stream_users_signup_userdata' to override the user data to update
 * @uses do_action() Calls 'wp_idea_stream_users_before_signup_field_required' to perform actions before required fields are checked
 *                   Calls 'wp_idea_stream_users_before_signup_user' to perform actions before signup is registered
 *                   Calls 'wp_idea_stream_users_after_signup_user' to perform actions after signup is registered
 *                   Calls 'wp_idea_stream_users_signup_user_created' to perform actions once the user created has been edited
 */
function wp_idea_stream_users_signup_user($exit = true)
{
    // Bail if not a post request
    if ('POST' != strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if not a post idea request
    if (empty($_POST['wp_idea_stream_signup']) || !is_array($_POST['wp_idea_stream_signup'])) {
        return;
    }
    // Check nonce
    check_admin_referer('wp_idea_stream_signup');
    $redirect = wp_idea_stream_get_redirect_url();
    $is_multisite = is_multisite();
    /**
     * Before registering the user, check for required field
     */
    $required_errors = new WP_Error();
    $user_login = false;
    if (!empty($_POST['wp_idea_stream_signup']['user_login'])) {
        $user_login = $_POST['wp_idea_stream_signup']['user_login'];
    }
    // Force the login to exist and to be at least 4 characters long
    if (4 > mb_strlen($user_login)) {
        $required_errors->add('user_login_fourchars', __('Please choose a login having at least 4 characters.', 'wp-idea-stream'));
    }
    $user_email = false;
    if (!empty($_POST['wp_idea_stream_signup']['user_email'])) {
        $user_email = $_POST['wp_idea_stream_signup']['user_email'];
    }
    // Do we need to edit the user once created ?
    $edit_user = array_diff_key($_POST['wp_idea_stream_signup'], array('signup' => 'signup', 'user_login' => 'user_login', 'user_email' => 'user_email'));
    /**
     * Perform actions before the required fields check
     *
     * @param  string $user_login the user login
     * @param  string $user_email the user email
     * @param  array  $edit_user  all extra user fields
     */
    do_action('wp_idea_stream_users_before_signup_field_required', $user_login, $user_email, $edit_user);
    foreach ($edit_user as $key => $value) {
        if (!apply_filters('wp_idea_stream_users_is_signup_field_required', false, $key)) {
            continue;
        }
        if (empty($value) && 'empty_required_field' != $required_errors->get_error_code()) {
            $required_errors->add('empty_required_field', __('Please fill all required fields.', 'wp-idea-stream'));
        }
    }
    // Stop the process and ask to fill all fields.
    if ($required_errors->get_error_code()) {
        //Add feedback to the user
        wp_idea_stream_add_message(array('type' => 'error', 'content' => join(' ', array_map('strip_tags', $required_errors->get_error_messages()))));
        return;
    }
    /**
     * Perform actions before the user is created
     *
     * @param  string $user_login the user login
     * @param  string $user_email the user email
     * @param  array  $edit_user  all extra user fields
     */
    do_action('wp_idea_stream_users_before_signup_user', $user_login, $user_email, $edit_user);
    // Defaults to user name and user email
    $signup_array = array('user_name' => $user_login, 'user_email' => $user_email);
    // Sanitize the signup on multisite configs.
    if (true === (bool) $is_multisite) {
        $signup_array = wpmu_validate_user_signup($user_login, $user_email);
        if (is_wp_error($signup_array['errors']) && $signup_array['errors']->get_error_code()) {
            //Add feedback to the user
            wp_idea_stream_add_message(array('type' => 'error', 'content' => join(' ', array_map('strip_tags', $signup_array['errors']->get_error_messages()))));
            return;
        }
        // Filter the rp login url for WordPress 4.3
        add_filter('wp_mail', 'wp_idea_stream_multisite_user_notification', 10, 1);
    }
    // Register the user
    $user = register_new_user($signup_array['user_name'], $signup_array['user_email']);
    // Stop filtering the rp login url
    if (true === (bool) $is_multisite) {
        remove_filter('wp_mail', 'wp_idea_stream_multisite_user_notification', 10, 1);
    }
    /**
     * Perform actions after the user is created
     *
     * @param  string             $user_login the user login
     * @param  string             $user_email the user email
     * @param  array              $edit_user  all extra user fields
     * @param  mixed int|WP_Error $user the user id or an error
     */
    do_action('wp_idea_stream_users_after_signup_user', $user_login, $user_email, $edit_user, $user);
    if (is_wp_error($user)) {
        //Add feedback to the user
        wp_idea_stream_add_message(array('type' => 'error', 'content' => join(' ', array_map('strip_tags', $user->get_error_messages()))));
        return;
        // User is created, now we need to eventually edit him
    } else {
        if (!empty($edit_user)) {
            $userdata = new stdClass();
            $userdata = (object) $edit_user;
            $userdata->ID = $user;
            /**
             * Just before the user is updated, this will only be available
             * if custom fields/contact methods are used.
             *
             * @param object $userdata the userdata to update
             */
            $userdata = apply_filters('wp_idea_stream_users_signup_userdata', $userdata);
            // Edit the user
            if (wp_update_user($userdata)) {
                /**
                 * Any extra field not using contact methods or WordPress built in user fields can hook here
                 *
                 * @param int $user the user id
                 * @param array $edit_user the submitted user fields
                 */
                do_action('wp_idea_stream_users_signup_user_created', $user, $edit_user);
            }
        }
        // Make sure an entry is added to the $wpdb->signups table
        if (true === (bool) $is_multisite) {
            wp_idea_stream_users_update_signups_table($user);
        }
        // Finally invite the user to check his email.
        wp_idea_stream_add_message(array('type' => 'success', 'content' => __('Registration complete. Please check your e-mail.', 'wp-idea-stream')));
        wp_safe_redirect($redirect);
        if ($exit) {
            exit;
        }
    }
}
Ejemplo n.º 13
0
 /**
  * Register new WP user from Gigya user.
  */
 private function register()
 {
     // Before we insert new user to the system, we check
     // if there is a user with the same email in our DB.
     // When there is we ask the user login in the
     // previous account and link it to the new one.
     $email_exists = email_exists($this->gigya_user['email']);
     if (!empty($email_exists)) {
         // Return JSON with login form to client.
         wp_send_json_success(array('type' => 'form', 'html' => $this->linkAccountForm($email_exists)));
     }
     // If the name of the new user already exists in the system,
     // WP will reject the registration and return an error. to prevent this
     // we attach an extra value to the name to make it unique.
     $username_exist = username_exists($this->gigya_user['nickname']);
     if (!empty($username_exist)) {
         $this->gigya_user['nickname'] .= uniqid('-');
     }
     // When the admin checked to
     // show the entire registration form to the user.
     if (!empty($this->login_options['registerExtra'])) {
         $this->registerExtraForm();
     }
     // Register a new user to WP with params from Gigya.
     $name = $this->gigya_user['nickname'];
     $email = $this->gigya_user['email'];
     // Hook just before register new user from Gigya Social Login.
     do_action('gigya_before_social_register', $name, $email);
     $user_id = register_new_user($name, $email);
     // On registration error.
     if (!empty($user_id->errors)) {
         $msg = '';
         foreach ($user_id->errors as $error) {
             foreach ($error as $err) {
                 $msg .= $err . "\n";
             }
         }
         // Return JSON to client.
         wp_send_json_error(array('msg' => $msg));
     }
     // map user social fields to wordpress user
     _gigya_add_to_wp_user_meta($this->{"gigya_user"}, $user_id);
     $wp_user = get_userdata($user_id);
     // If we got here, the user is already registered.
     // But if we have the 'email_not_verified' flag turned on,
     // we can't auto login, and we need to verify the email first.
     if (!empty($this->gigya_user['email_not_verified'])) {
         // Return JSON with login form to client.
         wp_send_json_success(array('type' => 'form', 'html' => $this->emailVerifyForm()));
     }
     // Finally, let's login the user.
     $this->login($wp_user);
 }
Ejemplo n.º 14
0
 case 'register':
     if (!get_option('users_can_register')) {
         wp_redirect(simplelogin_url(array('registration' => 'disabled')));
         exit;
     }
     if ($http_post) {
         require_once ABSPATH . WPINC . '/registration.php';
         $user_login = $_POST['user_login'];
         $user_email = $_POST['user_email'];
         $user_pass1 = '';
         $user_pass2 = '';
         if ($this->GetOption('allow_user_pass')) {
             $user_pass1 = $_POST['pass1'];
             $user_pass2 = $_POST['pass2'];
         }
         $login_errors = register_new_user($user_login, $user_email, $user_pass1, $user_pass2);
         if (!is_wp_error($login_errors)) {
             wp_redirect(simplelogin_url(array('action' => 'login', 'checkemail' => 'registered')));
             exit;
         }
     }
     break;
 case 'login':
     $secure_cookie = '';
     // If the user wants ssl but the session is not ssl, force a secure cookie.
     if (!empty($_POST['log']) && !force_ssl_admin()) {
         $user_name = sanitize_user($_POST['log']);
         if ($user = get_userdatabylogin($user_name)) {
             if (get_user_option('use_ssl', $user->ID)) {
                 $secure_cookie = true;
                 force_ssl_admin(true);
    public function login_init_callback()
    {
        global $action;
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
        $errors = new WP_Error();
        if (isset($_GET['key'])) {
            $action = 'resetpass';
        }
        // validate action so as to default to the login screen
        if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', $this->new_action, 'register', 'login'), true) && false === has_filter('login_form_' . $action)) {
            $action = 'login';
        }
        $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
        switch ($action) {
            case 'register':
                //Registration using 'register' action is now disabled!
                wp_redirect(site_url('wp-login.php?registration=disabled'));
                exit;
            case $this->new_action:
                //$action = 'register';
                if (is_multisite()) {
                    // Multisite uses wp-signup.php
                    wp_redirect(apply_filters('wp_signup_location', site_url('wp-signup.php')));
                    exit;
                }
                if (!get_option('users_can_register')) {
                    wp_redirect(site_url('wp-login.php?registration=disabled'));
                    exit;
                }
                $user_login = '';
                $user_email = '';
                if ($http_post) {
                    $user_login = $_POST['user_login'];
                    $user_email = $_POST['user_email'];
                    $errors = register_new_user($user_login, $user_email);
                    if (!is_wp_error($errors)) {
                        $redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
                        wp_safe_redirect($redirect_to);
                        exit;
                    }
                }
                $redirect_to = apply_filters('registration_redirect', !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '');
                login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
                ?>

			<form name="registerform" id="registerform" action="<?php 
                echo site_url('wp-login.php?action=' . $this->new_action, 'login_post');
                ?>
" method="post">
				<p>
					<label><?php 
                _e('Username');
                ?>
<br />
					<input type="text" name="user_login" id="user_login" class="input" value="<?php 
                echo esc_attr(stripslashes($user_login));
                ?>
" size="20" tabindex="10" /></label>
				</p>
				<p>
					<label><?php 
                _e('E-mail');
                ?>
<br />
					<input type="text" name="user_email" id="user_email" class="input" value="<?php 
                echo esc_attr(stripslashes($user_email));
                ?>
" size="25" tabindex="20" /></label>
				</p>
			<?php 
                do_action('register_form');
                ?>
				<p id="reg_passmail"><?php 
                _e('A password will be e-mailed to you.');
                ?>
</p>
				<br class="clear" />
				<input type="hidden" name="redirect_to" value="<?php 
                echo esc_attr($redirect_to);
                ?>
" />
				<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php 
                esc_attr_e('Register');
                ?>
" tabindex="100" /></p>
			</form>

			<p id="nav">
			<a href="<?php 
                echo site_url('wp-login.php', 'login');
                ?>
"><?php 
                _e('Log in');
                ?>
</a> |
			<a href="<?php 
                echo site_url('wp-login.php?action=lostpassword', 'login');
                ?>
" title="<?php 
                _e('Password Lost and Found');
                ?>
"><?php 
                _e('Lost your password?');
                ?>
</a>
			</p>

			<?php 
                login_footer('user_login');
                //break;
                exit;
        }
    }
Ejemplo n.º 16
0
 /**
  * Checks post data and registers user, then exits
  * @return string
  */
 public static function register()
 {
     $return = array();
     if (!function_exists('register_new_user')) {
         include_once 'registration.php';
         //in ajax we don't have access to this function, so include our own copy of the function
     }
     $errors = register_new_user($_POST['user_login'], $_POST['user_email']);
     if (!is_wp_error($errors)) {
         //Success
         $return['result'] = true;
         $return['message'] = __('Registration complete. Please check your e-mail.', 'login-with-ajax');
         //add user to blog if multisite
         if (is_multisite()) {
             add_user_to_blog(get_current_blog_id(), $errors, 'subscriber');
         }
     } else {
         //Something's wrong
         $return['result'] = false;
         $return['error'] = $errors->get_error_message();
     }
     $return['action'] = 'register';
     return $return;
 }
 /**
  * Checks post data and registers user
  * @return string
  */
 function register()
 {
     if (!empty($_REQUEST['lwa'])) {
         $return = array();
         if ('POST' == $_SERVER['REQUEST_METHOD']) {
             require_once ABSPATH . WPINC . '/registration.php';
             $errors = register_new_user($_POST['user_login'], $_POST['user_email']);
             if (!is_wp_error($errors)) {
                 //Success
                 $return['result'] = true;
                 $return['message'] = __('Registration complete. Please check your e-mail.');
             } else {
                 //Something's wrong
                 $return['result'] = false;
                 $return['error'] = $errors->get_error_message();
             }
         }
         echo $this->json_encode($return);
         exit;
     }
 }
Ejemplo n.º 18
0
 /**
  * Registers a new user. Supports multisite.
  */
 public function register()
 {
     if (!get_option('users_can_register')) {
         $error = new WP_Error();
         $error->add('users_cannot_register', __('Registration is not enabled for this site.'));
         return $error;
     }
     $user_name = $_POST['user_name'];
     $user_email = $_POST['user_email'];
     if (empty($user_name) || empty($user_email)) {
         $errors = new WP_Error();
         if (empty($user_name)) {
             $errors->add('username_required', __("A username is required."));
         }
         if (empty($user_email)) {
             $errors->add('email_required', __("A email is required."));
         }
         return $errors;
     }
     $result = wpmu_validate_user_signup($user_name, $user_email);
     extract($result);
     if ($errors->get_error_code()) {
         return $errors;
     }
     /** This filter is documented in wp-signup.php */
     $meta = apply_filters('add_signup_meta', array());
     // this also sends out email
     if (is_multisite()) {
         // Note: filters and admin options can prevent the email from being sent
         // but the user will still be signed up
         // this call was taking up to a minute!!!
         // update- a lot of calls were taking a while - not sure what is going on
         $emailSent = wpmu_signup_user($user_name, $user_email, $meta);
         $user = get_user_by('login', $user_name);
         $userId = $user ? $user->ID : -1;
         // seems to be null??
     } else {
         $userId = register_new_user($user_name, $user_email);
     }
     if (is_wp_error($result)) {
         return $result;
     }
     $result = array('status' => 'ok', 'user_name' => $user_name, 'user_email' => $user_email, 'created' => (bool) true);
     // multisite call returns -1 so not consistent
     // i'm guessing user must activate their account to get an id
     //if ($userId!=-1) {
     //	$result['id'] = $userId;
     //}
     return $result;
 }
Ejemplo n.º 19
0
 /**
  * Modifies the default registration page
  *
  * @since 	1.0
  */
 function view_registration_page()
 {
     global $errors;
     $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
     if ($http_post) {
         $action = $_POST['wp-submit'];
         $marketplace_username = isset($_POST['marketplace_username']) ? esc_attr($_POST['marketplace_username']) : '';
         $purchase_code = esc_attr($_POST['purchase_code']);
         $verify = $this->verify_purchase($marketplace_username, $purchase_code);
         if ($action == 'Register') {
             if (!is_wp_error($verify)) {
                 $user_login = $_POST['user_login'];
                 $user_email = $_POST['user_email'];
                 $errors = register_new_user($user_login, $user_email);
                 if (!is_wp_error($errors)) {
                     $user_id = $errors;
                     // Change role
                     wp_update_user(array('ID' => $user_id, 'role' => 'participant'));
                     // Update user meta
                     $items = array();
                     $items[$purchase_code] = array('name' => $verify['item_name'], 'id' => $verify['item_id'], 'date' => $verify['created_at'], 'buyer' => $verify['buyer'], 'licence' => $verify['licence'], 'purchase_code' => $verify['purchase_code']);
                     update_user_meta($user_id, 'purchased_items', $items);
                     $redirect_to = 'wp-login.php?checkemail=registered';
                     wp_safe_redirect($redirect_to);
                     exit;
                 } else {
                     $this->view_registration_form($errors, $verify);
                 }
             } else {
                 // Force to resubmit verify form
                 $this->view_verification_form($verify);
             }
         } elseif ($action == 'Verify') {
             // Verified, supply the registration form
             if (!is_wp_error($verify)) {
                 // Purchase Item Info
                 $this->view_registration_form($errors, $verify);
             } else {
                 // Force to resubmit verify form
                 $this->view_verification_form($verify);
             }
         }
     } else {
         $this->view_verification_form();
     }
     $this->custom_style();
     exit;
 }
Ejemplo n.º 20
0
 /**
  * Register new WP user from Gigya user.
  */
 private function register()
 {
     // Register a new user to WP with params from Gigya.
     if (isset($this->gigya_account['profile']['username'])) {
         $name = $this->gigya_account['profile']['username'];
     } else {
         $name = $this->gigya_account['profile']['firstName'] . '_' . $this->gigya_account['profile']['lastName'];
     }
     $email = $this->gigya_account['profile']['email'];
     // If the name of the new user already exists in the system,
     // WP will reject the registration and return an error. to prevent this
     // we attach an extra value to the name to make it unique.
     $username_exist = username_exists($name);
     if (!empty($username_exist)) {
         $name .= uniqid('-');
     }
     // Hook just before register new user from Gigya RaaS.
     do_action('gigya_before_raas_register', $name, $email);
     $user_id = register_new_user($name, $email);
     // On registration error.
     if (!empty($user_id->errors)) {
         $msg = '';
         foreach ($user_id->errors as $error) {
             foreach ($error as $err) {
                 $msg .= $err . "\n";
             }
         }
         // Return JSON to client.
         wp_send_json_error(array('msg' => $msg));
     }
     _gigya_add_to_wp_user_meta($this->gigya_account['profile'], $user_id);
     // Login the user.
     $wp_user = get_userdata($user_id);
     $this->login($wp_user);
 }
function cimy_confirmation_form()
{
    if (empty($_POST['register_confirmation'])) {
        return;
    }
    $confirmation = false;
    $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
    $user_login = '';
    $user_email = '';
    if ($http_post) {
        $user_login = $_POST['user_login'];
        $user_email = $_POST['user_email'];
        if (function_exists("register_new_user")) {
            // fake registration to check if no errors then we'll proceed to confirmation phase
            $fake_errors = register_new_user($user_login, $user_email);
            // ok we can remove registration checks
            // 			remove_action('register_post', 'cimy_registration_check', 10);
            // 			remove_action('register_post', 'cimy_registration_captcha_check', 9);
        } else {
            return;
        }
        if (!is_wp_error($fake_errors)) {
            $redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
            wp_safe_redirect($redirect_to);
            exit;
        } else {
            if (count($fake_errors->errors) == 1 && isset($fake_errors->errors["register_confirmation"])) {
                $confirmation = true;
            }
        }
    }
    if ($confirmation) {
        global $cimy_uef_domain;
        $redirect_to = apply_filters('registration_redirect', !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '');
        $message = new WP_Error();
        $message->add('confirmation', __('Confirm your registration', $cimy_uef_domain), 'message');
        login_header(__("Confirm your registration", $cimy_uef_domain), "", $message);
        ?>
		<form name="registerform" id="registerform" action="<?php 
        echo site_url('wp-login.php?action=register', 'login_post');
        ?>
" method="post">
<?php 
        cimy_registration_form(null, 2);
        ?>
		<p id="reg_passmail"><?php 
        _e('A password will be e-mailed to you.');
        ?>
</p>
		<br class="clear" />
		<input type="hidden" name="redirect_to" value="<?php 
        echo esc_attr($redirect_to);
        ?>
" />
		<?php 
        wp_nonce_field('confirm_form', 'confirm_form_nonce');
        ?>
		<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php 
        esc_attr_e('Register');
        ?>
" tabindex="100" /></p>
		</form>

		<p id="nav">
		<a href="javascript: history.go(-1)"><?php 
        _e('&larr; Back', $cimy_uef_domain);
        ?>
</a>
		</p>
<?php 
        login_footer("");
        exit(0);
    }
}
Ejemplo n.º 22
0
function cupid_sign_up_ajax_callback()
{
    include_once ABSPATH . WPINC . '/ms-functions.php';
    include_once ABSPATH . WPINC . '/user.php';
    ob_start();
    global $wpdb;
    //We shall SQL escape all inputs to avoid sql injection.
    $user_name = esc_sql($_REQUEST['username']);
    $user_email = esc_sql($_REQUEST['email']);
    $error = wpmu_validate_user_signup($user_name, $user_email);
    $code = 1;
    $message = '';
    if ($error['errors']->get_error_code() != '') {
        $code = -1;
        foreach ($error['errors']->get_error_messages() as $key => $value) {
            $message .= '<div/>' . __('<strong>ERROR:</strong> ', 'cupid') . esc_html($value) . '</div>';
        }
    } else {
        register_new_user($user_name, $user_email);
    }
    $response_data = array('code' => $code, 'message' => $message);
    ob_end_clean();
    echo json_encode($response_data);
    die;
    // this is required to return a proper result
}
Ejemplo n.º 23
0
 /**
  * @ticket 27317
  * @dataProvider _illegal_user_logins_data
  */
 function test_illegal_user_logins_single_wp_create_user($user_login)
 {
     $user_email = 'testuser-' . $user_login . '@example.com';
     add_filter('illegal_user_logins', array($this, '_illegal_user_logins'));
     $response = register_new_user($user_login, $user_email);
     $this->assertInstanceOf('WP_Error', $response);
     $this->assertEquals('invalid_username', $response->get_error_code());
     remove_filter('illegal_user_logins', array($this, '_illegal_user_logins'));
     $response = register_new_user($user_login, $user_email);
     $user = get_user_by('id', $response);
     $this->assertInstanceOf('WP_User', $user);
 }
Ejemplo n.º 24
0
        return null;
    } else {
        return $relative_url;
    }
}
if (isset($_REQUEST["operation"]) && $_REQUEST["operation"] == 'login') {
    //
    //	Log in ajax handler
    //
    $r = authentication_user($_REQUEST, $conn);
    echo $r;
} else {
    if (isset($_REQUEST["signout"])) {
        //
        //	Sign out ajax handler
        //
        sign_out_user($_SESSION["email"], $conn);
        echo relative_url("home.php");
    } else {
        if (isset($_REQUEST["operation"]) && $_REQUEST["operation"] == 'register') {
            //
            //	Register new user
            //
            $r = register_new_user($_REQUEST, $conn);
            echo $r;
        } else {
            echo "fail";
        }
    }
}
mysql_close($conn);
Ejemplo n.º 25
0
      *
      * @param string $sign_up_url The sign up URL.
      */
     wp_redirect(apply_filters('wp_signup_location', network_site_url('wp-signup.php')));
     exit;
 }
 if (!get_option('users_can_register')) {
     wp_redirect(site_url('wp-login.php?registration=disabled'));
     exit;
 }
 $user_login = '';
 $user_email = '';
 if ($http_post) {
     $user_login = isset($_POST['user_login']) ? $_POST['user_login'] : '';
     $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
     $errors = register_new_user($user_login, $user_email);
     if (!is_wp_error($errors)) {
         $redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
         wp_safe_redirect($redirect_to);
         exit;
     }
 }
 $registration_redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
 /**
  * Filter the registration redirect URL.
  *
  * @since 3.0.0
  *
  * @param string $registration_redirect The redirect destination URL.
  */
 $redirect_to = apply_filters('registration_redirect', $registration_redirect);
Ejemplo n.º 26
0
 public static function ajax_check_prosite_blog()
 {
     global $psts, $current_site;
     $blog_data = array();
     // Add ajax session var
     ProSites_Helper_Session::session('psts_ajax_session_activated', true);
     // Introduce a fake error because we don't want to actually create the blog yet.
     add_filter('registration_errors', array('ProSites_Model_Registration', 'prosite_blog_check_only'), 10, 3);
     // replace $_POST with array data
     $params = array();
     parse_str($_POST['data'], $params);
     $period = (int) $_POST['period'];
     $level = 'free' == $_POST['level'] ? $_POST['level'] : (int) $_POST['level'];
     $_POST = $params;
     $doing_ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false;
     $ajax_response = array();
     if ($doing_ajax) {
         $user_name = sanitize_text_field($_POST['user_name']);
         $user_email = sanitize_email($_POST['user_email']);
         $blogname = sanitize_text_field($_POST['blogname']);
         $blog_title = sanitize_text_field(urldecode($_POST['blog_title']));
         // Process some cleaning up if needed
         do_action('prosite_register_blog_pre_validation', $user_name, $user_email, $blogname);
         $blog_validation = wpmu_validate_blog_signup($blogname, $blog_title);
         // Attempt to create a new user (knowing that it will fail, but it should only have our error)
         if (!isset($_POST['new_blog'])) {
             $validation = wpmu_validate_user_signup($user_name, $user_email);
             // nicer errors, but doesn't deal with custom fields
             $user_check = register_new_user($user_name, $user_email);
             // checks custom fields, but ugly errors
             $user_check->errors = array_merge($user_check->errors, $validation['errors']->errors);
             $user_check->errors = array_merge($user_check->errors, $blog_validation['errors']->errors);
         } else {
             $user_check = new WP_Error();
             $user_check->errors = array_merge($user_check->errors, $blog_validation['errors']->errors);
         }
         // Replaced session vars to make it semi-stateless, will pick these up in a session later
         $blog_data['new_blog_details'] = array();
         $blog_data['new_blog_details']['username'] = $user_name;
         $blog_data['new_blog_details']['email'] = $user_email;
         $blog_data['new_blog_details']['blogname'] = $blogname;
         $blog_data['new_blog_details']['title'] = $blog_title;
         $blog_data['new_blog_details']['level'] = $level;
         $blog_data['new_blog_details']['period'] = $period;
         $username_available = true;
         $email_available = true;
         $blogname_available = true;
         $blogtitle_available = true;
         // Checking passed...
         if (!empty($user_check->errors) && 1 == count($user_check->errors) && !isset($_POST['new_blog']) || 0 == count($user_check->errors) && isset($_POST['new_blog'])) {
             $keys = array_keys($user_check->errors);
             if ($keys && !in_array('availability_check_only', $keys) && !isset($_POST['new_blog'])) {
                 // Something went wrong!
                 $ajax_response['user_available'] = false;
             } else {
                 // All good!  We're ready to create the user/site
                 /** User is validated using register_new_user so that we can use the hooks and make them available,
                  * but we still need to actually create and activate the signup to get the $user_id. */
                 $blog = $blog_validation;
                 $domain = $blog['domain'];
                 $path = $blog['path'];
                 $blogname = $blog['blogname'];
                 $blog_title = $blog['blog_title'];
                 $errors = $blog['errors'];
                 // Privacy setting
                 $public = (int) $_POST['blog_public'];
                 $signup_meta = array('lang_id' => 1, 'public' => $public);
                 // Create the signup
                 $meta = apply_filters('add_signup_meta', $signup_meta);
                 $result = ProSites_Helper_Registration::signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
                 $blog_data['activation_key'] = $result['activation_key'];
                 if (isset($result['user_pass']) && !empty($result['user_pass'])) {
                     $blog_data['new_blog_details']['user_pass'] = $result['user_pass'];
                 }
                 $trial_days = $psts->get_setting('trial_days', 0);
                 $trial_active = !empty($trial_days);
                 $site_name = '';
                 if (!is_subdomain_install()) {
                     $site_name = $current_site->domain . $current_site->path . $blogname;
                 } else {
                     $site_name = $blogname . '.' . ($site_domain = preg_replace('|^www\\.|', '', $current_site->domain));
                 }
                 if ($trial_active) {
                     $recurring = $psts->get_setting('recurring_subscriptions', 1);
                     if ($recurring) {
                         $blog_data['new_blog_details']['reserved_message'] = sprintf('<div class="reserved_msg"><h2>' . __('Activate your site', 'psts') . '</h2>' . __('<p>Your site <strong>(%s)</strong> has been reserved but is not yet activated.</p><p>Once payment information has been verified your trial period will begin. When your trial ends you will be automatically upgraded to your chosen plan. Your reservation only last for 48 hours upon which your site name will become available again.</p><p>Please use the form below to setup your payment information.</p>', 'psts') . '</div>', $site_name);
                     } else {
                         // Non-recurring sites really should not do anything at checkout other than activate.
                         $result = ProSites_Helper_Registration::activate_blog($blog_data, true, $period, $level);
                         $blog_id = $result['blog_id'];
                         if (isset($result['password'])) {
                             $blog_data['new_blog_details']['user_pass'] = $result['password'];
                         }
                         ProSites_Helper_Registration::set_trial($blog_id, 1);
                         //Update Activation Key for blog
                         ProSites_Helper_Registration::update_activation_key($blog_id, $blog_data['activation_key']);
                         $psts->record_stat($blog_id, 'signup');
                         $ajax_response['show_finish'] = true;
                         $ajax_response['finish_content'] = ProSites_View_Front_Gateway::render_payment_submitted($blog_data, true);
                     }
                 } else {
                     $blog_data['new_blog_details']['reserved_message'] = sprintf('<div class="reserved_msg"><h2>' . __('Activate your site', 'psts') . '</h2>' . __('<p>Your site <strong>(%s)</strong> has been reserved but is not yet activated.</p><p>Once payment has been processed your site will become active with your chosen plan. Your reservation only last for 48 hours upon which your site name will become available again.</p><p>Please use the form below to setup your payment information.</p>', 'psts') . '</div>', $site_name);
                 }
                 // FREE basic site
                 if ('free' == $blog_data['new_blog_details']['level']) {
                     if (isset($blog_data['new_blog_details']['reserved_message'])) {
                         unset($blog_data['new_blog_details']['reserved_message']);
                     }
                     $result = ProSites_Helper_Registration::activate_blog($blog_data, false, false, false);
                     $blog_data['new_blog_details']['blog_id'] = $result['blog_id'];
                     if (isset($result['password'])) {
                         $blog_data['new_blog_details']['user_pass'] = $result['password'];
                     }
                     $ajax_response['show_finish'] = true;
                     $ajax_response['finish_content'] = ProSites_View_Front_Gateway::render_free_confirmation($blog_data);
                 }
                 if (isset($blog_data['new_blog_details']['reserved_message'])) {
                     $ajax_response['reserved_message'] = $blog_data['new_blog_details']['reserved_message'];
                 }
             }
             // If WP 4.0+ and user is logged in it will use WP_Session_Tokens, else $_SESSION
             ProSites_Helper_Session::session('new_blog_details', $blog_data['new_blog_details']);
             ProSites_Helper_Session::session('activation_key', $blog_data['activation_key']);
             $ajax_response['gateways_form'] = ProSites_View_Front_Gateway::render_checkout($blog_data);
         } else {
             // We had registration errors, redraw the form displaying errors
             if (!empty($user_check) && isset($user_check->errors)) {
                 $ajax_response['form'] = ProSites_View_Front_Registration::render_signup_form($blog_data, $user_check);
                 $ajax_response['user_available'] = false;
             }
             // Isolate which standard fields are valid
             $error_keys = array_keys($user_check->errors);
             foreach ($error_keys as $key) {
                 if (preg_match('/username|user_name/', $key)) {
                     $username_available = false;
                 }
                 if (preg_match('/email/', $key)) {
                     $email_available = false;
                 }
                 if (preg_match('/blogname/', $key)) {
                     $blogname_available = false;
                 }
                 if (preg_match('/blog_title/', $key)) {
                     $blogtitle_available = false;
                 }
             }
         }
         $ajax_response['username_available'] = $username_available;
         $ajax_response['email_available'] = $email_available;
         $ajax_response['blogname_available'] = $blogname_available;
         $ajax_response['blog_title_available'] = $blogtitle_available;
         $response = array('what' => 'response', 'action' => 'check_prosite_blog', 'id' => 1, 'data' => json_encode($ajax_response));
         // No longer need ajax session
         ProSites_Helper_Session::unset_session('psts_ajax_session_activated');
         // Buffer used to isolate AJAX response from unexpected output
         @ob_end_clean();
         ob_start();
         $xmlResponse = new WP_Ajax_Response($response);
         $xmlResponse->send();
         ob_end_flush();
     }
 }
Ejemplo n.º 27
0
 public function ap_ajax_signup()
 {
     if (is_user_logged_in()) {
         return;
     }
     // create user
     $user_id = register_new_user($_POST['username'], $_POST['email']);
     // return if there is any error
     if (is_wp_error($user_id)) {
         return;
     }
     if (is_wp_error($user_id)) {
         $result = array('status' => false, 'message' => __('Unable to create account, please try again.', 'ap'));
     } else {
         $result = array('status' => true, 'message' => __('Successfully created your account, please check your email for password.', 'ap'));
     }
     die(json_encode($result));
 }
Ejemplo n.º 28
0
function rcl_get_register_user_activate()
{
    if (isset($_POST['submit-register'])) {
        //если данные пришли с формы wp-recall
        if (!wp_verify_nonce($_POST['_wpnonce'], 'register-key-rcl')) {
            return false;
        }
        $email = $_POST['user_email'];
        $login = sanitize_user($_POST['user_login']);
        register_new_user($login, $email);
        //add_action( 'wp', 'rcl_get_register_user',999 );
    }
    /*if(isset($_POST['wp-submit'])&&$_GET['action']=='register'){ //если данные пришли со страницы wp-login.php
          add_filter('registration_errors','rcl_get_register_user',999);
      }*/
}
 /**
  * Proccesses the request
  *
  * Callback for "template_redirect" hook in template-loader.php
  *
  * @since 6.3
  * @access public
  */
 public function template_redirect()
 {
     $this->request_action = isset($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : '';
     if (!$this->request_action && self::is_tml_page()) {
         $this->request_action = self::get_page_action(get_the_id());
     }
     $this->request_instance = isset($_REQUEST['instance']) ? sanitize_key($_REQUEST['instance']) : 0;
     do_action_ref_array('tml_request', array(&$this));
     // allow plugins to override the default actions, and to add extra actions if they want
     do_action('login_form_' . $this->request_action);
     if (has_action('tml_request_' . $this->request_action)) {
         do_action_ref_array('tml_request_' . $this->request_action, array(&$this));
     } else {
         $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
         switch ($this->request_action) {
             case 'postpass':
                 if (!array_key_exists('post_password', $_POST)) {
                     wp_safe_redirect(wp_get_referer());
                     exit;
                 }
                 require_once ABSPATH . 'wp-includes/class-phpass.php';
                 $hasher = new PasswordHash(8, true);
                 $expire = apply_filters('post_password_expires', time() + 10 * DAY_IN_SECONDS);
                 if ($referer) {
                     $secure = 'https' === parse_url($referer, PHP_URL_SCHEME);
                 } else {
                     $secure = false;
                 }
                 setcookie('wp-postpass_' . COOKIEHASH, $hasher->HashPassword(wp_unslash($_POST['post_password'])), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure);
                 wp_safe_redirect(wp_get_referer());
                 exit;
                 break;
             case 'logout':
                 check_admin_referer('log-out');
                 $user = wp_get_current_user();
                 wp_logout();
                 if (!empty($_REQUEST['redirect_to'])) {
                     $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
                 } else {
                     $redirect_to = site_url('wp-login.php?loggedout=true');
                     $requested_redirect_to = '';
                 }
                 $redirect_to = apply_filters('logout_redirect', $redirect_to, $requested_redirect_to, $user);
                 wp_safe_redirect($redirect_to);
                 exit;
                 break;
             case 'lostpassword':
             case 'retrievepassword':
                 if ($http_post) {
                     $this->errors = self::retrieve_password();
                     if (!is_wp_error($this->errors)) {
                         $redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url('wp-login.php?checkemail=confirm');
                         wp_safe_redirect($redirect_to);
                         exit;
                     }
                 }
                 if (isset($_REQUEST['error'])) {
                     if ('invalidkey' == $_REQUEST['error']) {
                         $this->errors->add('invalidkey', __('Your password reset link appears to be invalid. Please request a new link below.', 'theme-my-login'));
                     } elseif ('expiredkey' == $_REQUEST['error']) {
                         $this->errors->add('expiredkey', __('Your password reset link has expired. Please request a new link below.', 'theme-my-login'));
                     }
                 }
                 do_action('lost_password');
                 break;
             case 'resetpass':
             case 'rp':
                 // Dirty hack for now
                 global $rp_login, $rp_key;
                 list($rp_path) = explode('?', wp_unslash($_SERVER['REQUEST_URI']));
                 $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
                 if (isset($_GET['key'])) {
                     $value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key']));
                     setcookie($rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true);
                     wp_safe_redirect(remove_query_arg(array('key', 'login')));
                     exit;
                 }
                 if (isset($_COOKIE[$rp_cookie]) && 0 < strpos($_COOKIE[$rp_cookie], ':')) {
                     list($rp_login, $rp_key) = explode(':', wp_unslash($_COOKIE[$rp_cookie]), 2);
                     $user = check_password_reset_key($rp_key, $rp_login);
                     if (isset($_POST['pass1']) && !hash_equals($rp_key, $_POST['rp_key'])) {
                         $user = false;
                     }
                 } else {
                     $user = false;
                 }
                 if (!$user || is_wp_error($user)) {
                     setcookie($rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true);
                     if ($user && $user->get_error_code() === 'expired_key') {
                         wp_redirect(site_url('wp-login.php?action=lostpassword&error=expiredkey'));
                     } else {
                         wp_redirect(site_url('wp-login.php?action=lostpassword&error=invalidkey'));
                     }
                     exit;
                 }
                 if (isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2']) {
                     $this->errors->add('password_reset_mismatch', __('The passwords do not match.', 'theme-my-login'));
                 }
                 do_action('validate_password_reset', $this->errors, $user);
                 if (!$this->errors->get_error_code() && isset($_POST['pass1']) && !empty($_POST['pass1'])) {
                     reset_password($user, $_POST['pass1']);
                     setcookie($rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true);
                     $redirect_to = site_url('wp-login.php?resetpass=complete');
                     wp_safe_redirect($redirect_to);
                     exit;
                 }
                 wp_enqueue_script('utils');
                 wp_enqueue_script('user-profile');
                 break;
             case 'register':
                 if (!get_option('users_can_register')) {
                     $redirect_to = site_url('wp-login.php?registration=disabled');
                     wp_redirect($redirect_to);
                     exit;
                 }
                 $user_login = '';
                 $user_email = '';
                 if ($http_post) {
                     if ('email' == $this->get_option('login_type')) {
                         $user_login = isset($_POST['user_email']) ? $_POST['user_email'] : '';
                     } else {
                         $user_login = isset($_POST['user_login']) ? $_POST['user_login'] : '';
                     }
                     $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
                     $this->errors = register_new_user($user_login, $user_email);
                     if (!is_wp_error($this->errors)) {
                         $redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : site_url('wp-login.php?checkemail=registered');
                         wp_safe_redirect($redirect_to);
                         exit;
                     }
                 }
                 break;
             case 'login':
             default:
                 $secure_cookie = '';
                 $interim_login = isset($_REQUEST['interim-login']);
                 // If the user wants ssl but the session is not ssl, force a secure cookie.
                 if (!empty($_POST['log']) && !force_ssl_admin()) {
                     $user_name = sanitize_user($_POST['log']);
                     if ($user = get_user_by('login', $user_name)) {
                         if (get_user_option('use_ssl', $user->ID)) {
                             $secure_cookie = true;
                             force_ssl_admin(true);
                         }
                     }
                 }
                 if (!empty($_REQUEST['redirect_to'])) {
                     $redirect_to = $_REQUEST['redirect_to'];
                     // Redirect to https if user wants ssl
                     if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
                         $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
                     }
                 } else {
                     $redirect_to = admin_url();
                 }
                 $reauth = empty($_REQUEST['reauth']) ? false : true;
                 if ($http_post && isset($_POST['log'])) {
                     $user = wp_signon('', $secure_cookie);
                     $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
                     if (!is_wp_error($user) && !$reauth) {
                         if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
                             // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
                             if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
                                 $redirect_to = user_admin_url();
                             } elseif (is_multisite() && !$user->has_cap('read')) {
                                 $redirect_to = get_dashboard_url($user->ID);
                             } elseif (!$user->has_cap('edit_posts')) {
                                 $redirect_to = $user->has_cap('read') ? admin_url('profile.php') : home_url();
                             }
                         }
                         wp_safe_redirect($redirect_to);
                         exit;
                     }
                     $this->errors = $user;
                 }
                 // Clear errors if loggedout is set.
                 if (!empty($_GET['loggedout']) || $reauth) {
                     $this->errors = new WP_Error();
                 }
                 // Some parts of this script use the main login form to display a message
                 if (isset($_GET['loggedout']) && true == $_GET['loggedout']) {
                     $this->errors->add('loggedout', __('You are now logged out.', 'theme-my-login'), 'message');
                 } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
                     $this->errors->add('registerdisabled', __('User registration is currently not allowed.', 'theme-my-login'));
                 } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
                     $this->errors->add('confirm', __('Check your e-mail for the confirmation link.', 'theme-my-login'), 'message');
                 } elseif (isset($_GET['resetpass']) && 'complete' == $_GET['resetpass']) {
                     $this->errors->add('password_reset', __('Your password has been reset.', 'theme-my-login'), 'message');
                 } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
                     $this->errors->add('registered', __('Registration complete. Please check your e-mail.', 'theme-my-login'), 'message');
                 } elseif ($interim_login) {
                     $this->errors->add('expired', __('Your session has expired. Please log-in again.', 'theme-my-login'), 'message');
                 } elseif (strpos($redirect_to, 'about.php?updated')) {
                     $this->errors->add('updated', __('<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.', 'theme-my-login'), 'message');
                 } elseif ($reauth) {
                     $this->errors->add('reauth', __('Please log in to continue.', 'theme-my-login'), 'message');
                 }
                 // Clear any stale cookies.
                 if ($reauth) {
                     wp_clear_auth_cookie();
                 }
                 break;
         }
         // end switch
     }
     // endif has_filter()
 }
Ejemplo n.º 30
-1
function sfc_register_redirect($fb)
{
    if (SFC_REGISTER_TRANSPARENT) {
        $fbuid = $fb->get_loggedin_user();
        // this is a facebook user, get the info
        if ($fbuid) {
            $user_details = $fb->api_client->users_getInfo($fbuid, 'name, proxied_email');
            if (is_array($user_details)) {
                $fbname = $user_details[0]['name'];
            }
            $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\"";
            $fbemail = $fb->api_client->fql_query($query);
            if (is_array($fbemail)) {
                $fbemail = $fbemail[0]['email'];
            }
        }
        // force create the user instantly
        require_once ABSPATH . WPINC . '/registration.php';
        $errors = register_new_user($fbname, $fbemail);
        if (!is_wp_error($errors)) {
            wp_redirect('wp-login.php?checkemail=registered');
            exit;
        }
    }
    wp_redirect('wp-login.php?action=register');
    exit;
}