/** * modify Social Connect redirect to url * @since 3.1.9 */ function cp_social_connect_redirect_to($redirect_to) { if (preg_match('#/wp-(admin|login)?(.*?)$#i', $redirect_to)) { $redirect_to = home_url(); } if (current_theme_supports('app-login')) { if (APP_Login::get_url('redirect') == $redirect_to || appthemes_get_registration_url('redirect') == $redirect_to) { $redirect_to = home_url(); } } return $redirect_to; }
<div class="form-field"> <div id="pass-strength-result" class="hide-if-no-js"><?php _e('Strength indicator', APP_TD); ?> </div> <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).', APP_TD); ?> </p> </div> <?php do_action('register_form'); ?> <div class="form-field"> <?php echo APP_Login::redirect_field(); ?> <input tabindex="30" type="submit" class="btn reg" id="register" name="register" value="<?php _e('Register', APP_TD); ?> " /> </div> </fieldset> <!-- autofocus the field --> <script type="text/javascript">try{document.getElementById('user_login').focus();}catch(e){}</script> </form>
/** * Return url of login page * * @param string $context * * @return string */ function appthemes_get_login_url($context = 'display', $redirect_to = '') { $args = wp_array_slice_assoc($_GET, array('checkemail', 'registration', 'loggedout')); if (!empty($redirect_to)) { $args['redirect_to'] = urlencode($redirect_to); } if (current_theme_supports('app-login') && ($page_id = APP_Login::get_id())) { $url = get_permalink($page_id); } else { $url = site_url('wp-login.php'); } $url = add_query_arg($args, $url); return esc_url($url, null, $context); }
function register_new_user() { $posted = array(); $errors = new WP_Error(); $user_pass = wp_generate_password(); $show_password_fields = apply_filters('show_password_fields_on_registration', true); // Get (and clean) data $fields = array('user_login', 'user_email', 'pass1', 'pass2'); foreach ($fields as $field) { if (isset($_POST[$field])) { $posted[$field] = stripslashes(trim($_POST[$field])); } } $sanitized_user_login = sanitize_user($posted['user_login']); $user_email = apply_filters('user_registration_email', $posted['user_email']); // Check the username if ($sanitized_user_login == '') { $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.', APP_TD)); } elseif (!validate_username($posted['user_login'])) { $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.', APP_TD)); $sanitized_user_login = ''; } elseif (username_exists($sanitized_user_login)) { $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', APP_TD)); } // Check the e-mail address if ($user_email == '') { $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', APP_TD)); } elseif (!is_email($user_email)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', APP_TD)); $user_email = ''; } elseif (email_exists($user_email)) { $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', APP_TD)); } do_action('register_post', $sanitized_user_login, $user_email, $errors); $errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email); if ($errors->get_error_code()) { $this->error = $errors; return $this->error; } if ($show_password_fields) { if (empty($posted['pass1'])) { $errors->add('empty_password', __('<strong>ERROR</strong>: Please enter a password.', APP_TD)); } elseif (empty($posted['pass2'])) { $errors->add('empty_password', __('<strong>ERROR</strong>: Please enter the password twice.', APP_TD)); } elseif (!empty($posted['pass1']) && $posted['pass1'] != $posted['pass2']) { $errors->add('password_mismatch', __('<strong>ERROR</strong>: The passwords do not match.', APP_TD)); } } if (current_theme_supports('app-recaptcha')) { list($options) = get_theme_support('app-recaptcha'); require_once $options['file']; // check and make sure the reCaptcha values match $resp = recaptcha_check_answer($options['private_key'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if (!$resp->is_valid) { $errors->add('invalid_recaptcha', __('<strong>ERROR</strong>: The reCaptcha anti-spam response was incorrect.', APP_TD)); } } if ($errors->get_error_code()) { $this->error = $errors; return $this->error; } if (isset($posted['pass1'])) { $user_pass = $posted['pass1']; } // create the account and pass back the new user id $user_id = wp_create_user($posted['user_login'], $user_pass, $posted['user_email']); // something went wrong captain if (!$user_id) { $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn't register you... please contact the <a href="mailto:%s">webmaster</a> !', APP_TD), get_option('admin_email'))); if ($errors->get_error_code()) { $this->error = $errors; return $this->error; } } do_action('appthemes_after_registration', $user_id, $user_pass); if ($show_password_fields) { // set the WP login cookie (log the user in) $secure_cookie = is_ssl() ? true : false; wp_set_auth_cookie($user_id, true, $secure_cookie); if (isset($_REQUEST['redirect_to'])) { $success_redirect = $_REQUEST['redirect_to']; } else { $success_redirect = get_option('siteurl'); } } else { // WP created password for user, so show a message that it's been emailed to him $success_redirect = add_query_arg('checkemail', 'newpass', APP_Login::get_url('redirect')); } // redirect wp_redirect($success_redirect); exit; }
/** * Return url of login page * * @param string $context * * @return string */ function appthemes_get_login_url($context = 'display', $redirect_to = '') { $args = array(); if (!empty($redirect_to)) { $args['redirect_to'] = urlencode($redirect_to); } if (current_theme_supports('app-login') && ($page_id = APP_Login::get_id())) { $url = get_permalink($page_id); } else { $url = site_url('wp-login.php'); } $url = add_query_arg($args, $url); return esc_url($url, null, $context); }