当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_setcookie函数代码示例

本文整理汇总了PHP中wp_setcookie函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_setcookie函数的具体用法?PHP wp_setcookie怎么用?PHP wp_setcookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_setcookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: comber_login_guest

function comber_login_guest()
{
    if (isset($_POST['comber_user_login']) && wp_verify_nonce($_POST['comber_login_nonce'], 'comber-login-nonce')) {
        // this returns the user ID and other info from the user name
        $user = get_userdatabylogin($_POST['comber_user_login']);
        if (!$user) {
            // if the user name doesn't exist
            comber_errors()->add('empty_username', __('Invalid username'));
        }
        if (!isset($_POST['comber_user_pass']) || $_POST['comber_user_pass'] == '') {
            // if no password was entered
            comber_errors()->add('empty_password', __('Please enter a password'));
        }
        // check the user's login with their password
        if (!wp_check_password($_POST['comber_user_pass'], $user->user_pass, $user->ID)) {
            // if the password is incorrect for the specified user
            comber_errors()->add('empty_password', __('Incorrect password'));
        }
        // retrieve all error messages
        $errors = comber_errors()->get_error_messages();
        // only log the user in if there are no errors
        if (empty($errors)) {
            wp_setcookie($_POST['comber_user_login'], $_POST['comber_user_pass'], true);
            wp_set_current_user($user->ID, $_POST['comber_user_login']);
            do_action('wp_login', $_POST['comber_user_login']);
            wp_redirect(home_url($_POST['current_page']));
            exit;
        } else {
            wp_redirect(home_url($_POST['current_page'] . '/?login=true&fail=true'));
            exit;
        }
    }
}
开发者ID:SaloCreative,项目名称:thecomberwedding.co.uk,代码行数:33,代码来源:process.php

示例2: wpmem_login

 /**
  * Logs in the user
  *
  * Logs in the the user using wp_signon (since 2.5.2). If login 
  * is successful, it redirects and exits; otherwise "loginfailed"
  * is returned.
  *
  * @since 0.1
  *
  * @uses apply_filters Calls 'wpmem_login_redirect' hook to get $redirect_to
  *
  * @uses wp_signon
  * @uses wp_redirect Redirects to $redirect_to if login is successful
  * @return string Returns "loginfailed" if the login fails
  */
 function wpmem_login()
 {
     if (isset($_POST['redirect_to'])) {
         $redirect_to = $_POST['redirect_to'];
     } else {
         $redirect_to = $_SERVER['PHP_SELF'];
     }
     $redirect_to = apply_filters('wpmem_login_redirect', $redirect_to);
     if (isset($_POST['rememberme']) == 'forever') {
         $rememberme = true;
     } else {
         $rememberme = false;
     }
     if ($_POST['log'] && $_POST['pwd']) {
         $user_login = sanitize_user($_POST['log']);
         $user_login = wpmem_login_check_for_email($user_login);
         $creds = array();
         $creds['user_login'] = $user_login;
         $creds['user_password'] = $_POST['pwd'];
         $creds['remember'] = $rememberme;
         $user = wp_signon($creds, false);
         if (!is_wp_error($user)) {
             if (!$using_cookie) {
                 wp_setcookie($user_login, $user_pass, false, '', '', $rememberme);
             }
             wp_redirect($redirect_to);
             exit;
         } else {
             return "loginfailed";
         }
     } else {
         //login failed
         return "loginfailed";
     }
 }
开发者ID:jimlongo56,项目名称:bhouse,代码行数:50,代码来源:wp-members-pluggable.php

示例3: unset

				}
            }
        }
        unset($cache_settings); // so they will be re-read
        get_settings('siteurl'); // make it happen now
    } // end if options
    
    if ($any_changed) {
			// If siteurl or home changed, reset cookies.
			if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
				// Get currently logged in user and password.
				get_currentuserinfo();
				// Clear cookies for old paths.
				wp_clearcookie();
				// Set cookies for new paths.
				wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
			}

			//$message = sprintf(__('%d setting(s) saved... '), $any_changed);
    }
    
		$referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
		$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
		$goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
    header('Location: ' . $goback);
    break;

default:
	include('admin-header.php'); ?>

<div class="wrap">
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:options.php

示例4: set_post_content_13

function set_post_content_13($entry, $form)
{
    //login, set cookies, and set current user
    $user_pass = md5($entry['2']);
    wp_login($entry['3'], $user_pass, true);
    wp_setcookie($entry['3'], $entry['2'], true);
    wp_set_current_user($user->ID, $user_login);
    if (isset($_SESSION['returnURL']) && !empty($_SESSION['returnURL'])) {
        $url = $_SESSION['returnURL'];
        $_SESSION['returnURL'] == '';
        header('Location: ' . $url);
    }
}
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:13,代码来源:functions.php

示例5: __

    } else {
        $random_password = __('User already exists.  Password inherited.');
    }
    $backuser_name = str_replace('@', '', $user_name);
    $backuser_name = str_replace('.', '-', $backuser_name);
    //echo $backuser_name;
    //echo('1');
    header("Location: /users/" . $backuser_name . "/profile/");
}
if ($_GET["from"] == 'signin') {
    $email = htmlspecialchars($_POST['email']);
    $login = get_user_by_email($email);
    $login = $login->user_login;
    $password = htmlspecialchars($_POST['password']);
    wp_login($login, $password, true);
    wp_setcookie($login, $password, true);
    $backuser_name = str_replace('@', '', $login);
    $backuser_name = str_replace('.', '-', $backuser_name);
    header("Location: /users/" . $backuser_name . "/profile/");
}
?>
 
<?php 
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$user_login = $current_user->user_login;
$backuser_name = str_replace('@', '', $user_login);
$backuser_name = str_replace('.', '-', $backuser_name);
if ($_GET["from"] == 'userdata') {
    $firstname = htmlspecialchars($_POST['firstnameinput']);
    $lastname = htmlspecialchars($_POST['lastnameinput']);
开发者ID:dimakos,项目名称:myj,代码行数:31,代码来源:handler.php

示例6: ob_start

<?php

ob_start();
include_once '../../../wp-config.php';
include_once '../../../wp-load.php';
if ($_REQUEST['login_username'] && $_REQUEST['login_password']) {
    $userdata = get_user_by('email', $_REQUEST['login_username']);
    if (isset($_REQUEST['rememberme']) && $_REQUEST['rememberme'] == 1) {
        $secure_cookie = true;
    } else {
        $secure_cookie = false;
    }
    $creds = array();
    $creds['user_login'] = $userdata->user_login;
    $creds['user_password'] = $_REQUEST['login_password'];
    $user = wp_signon($creds, $secure_cookie);
    if (is_wp_error($user)) {
        echo "0";
        die;
    } else {
        wp_setcookie($userdata->user_login, $_REQUEST['login_password'], true);
        wp_set_current_user($user->data->ID, $userdata->user_login);
        echo "1";
        die;
    }
}
开发者ID:domalexxx,项目名称:nashvancouver,代码行数:26,代码来源:user_login.php

示例7: do_action

     if (!empty($cookie_login)) {
         $using_cookie = true;
         $user_login = $cookie_login['login'];
         $user_pass = $cookie_login['password'];
     }
 }
 do_action('wp_authenticate', array(&$user_login, &$user_pass));
 if ($user_login && $user_pass) {
     $user = new WP_User(0, $user_login);
     // If the user can't edit posts, send them to their profile.
     if (!$user->has_cap('edit_posts') && (empty($redirect_to) || $redirect_to == 'wp-admin/')) {
         $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';
     }
     if (wp_login($user_login, $user_pass, $using_cookie)) {
         if (!$using_cookie) {
             wp_setcookie($user_login, $user_pass, false, '', '', $rememberme);
         }
         do_action('wp_login', $user_login);
         wp_safe_redirect($redirect_to);
         exit;
     } else {
         if ($using_cookie) {
             $error = __('Your session has expired.');
         }
     }
 } else {
     if ($user_login || $user_pass) {
         $error = __('<strong>Error</strong>: The password field is empty.');
     }
 }
 ?>
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:wp-login.php

示例8: do_action

                $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH];
            }
            if (!empty($_COOKIE['wordpresspass_' . COOKIEHASH])) {
                $user_pass = $_COOKIE['wordpresspass_' . COOKIEHASH];
                $using_cookie = true;
            }
        }
        do_action('wp_authenticate', array(&$user_login, &$user_pass));
        if ($user_login && $user_pass) {
            $user = get_userdatabylogin($user_login);
            if (0 == $user->user_level) {
                $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';
            }
            if (wp_login($user_login, $user_pass, $using_cookie)) {
                if (!$using_cookie) {
                    wp_setcookie($user_login, $user_pass);
                }
                do_action('wp_login', $user_login);
                wp_redirect($redirect_to);
                exit;
            } else {
                if ($using_cookie) {
                    $error = __('Your session has expired.');
                }
            }
        }
        if (isset($_REQUEST['redirect_to'])) {
            $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $_REQUEST['redirect_to']);
        }
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:31,代码来源:wp-login.php

示例9: update_home_siteurl

function update_home_siteurl( $old_value, $value ) {
	global $wp_rewrite, $user_login, $user_pass_md5;

	if ( defined( "WP_INSTALLING" ) )
		return;

	// If home changed, write rewrite rules to new location.
	$wp_rewrite->flush_rules();
	// Clear cookies for old paths.
	wp_clearcookie();
	// Set cookies for new paths.
	wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' ));
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:13,代码来源:admin-functions.php

示例10: openid_create_new_user

/**
 * Create a new WordPress user with the specified identity URL and user data.
 *
 * @param string $identity_url OpenID to associate with the newly
 * created account
 * @param array $user_data array of user data
 */
function openid_create_new_user($identity_url, &$user_data) {
	global $wpdb;

	// Identity URL is new, so create a user
	@include_once( ABSPATH . 'wp-admin/upgrade-functions.php');	// 2.1
	@include_once( ABSPATH . WPINC . '/registration-functions.php'); // 2.0.4

	// otherwise, try to use preferred username
	if ( empty($username) && array_key_exists('nickname', $user_data) ) {
		$username = openid_generate_new_username($user_data['nickname'], false);
	}

	// finally, build username from OpenID URL
	if (empty($username)) {
		$username = openid_generate_new_username($identity_url);
	}

	$user_data['user_login'] = $username;
	$user_data['user_pass'] = substr( md5( uniqid( microtime() ) ), 0, 7);
	$user_id = wp_insert_user( $user_data );

	if( $user_id ) { // created ok

		$user_data['ID'] = $user_id;
		// XXX this all looks redundant, see openid_set_current_user

		$user = new WP_User( $user_id );

		if( ! wp_login( $user->user_login, $user_data['user_pass'] ) ) {
			openid_message(__('User was created fine, but wp_login() for the new user failed. This is probably a bug.', 'openid'));
			openid_status('error');
			openid_error(openid_message());
			return;
		}

		// notify of user creation
		wp_new_user_notification( $user->user_login );

		wp_clearcookie();
		wp_setcookie( $user->user_login, md5($user->user_pass), true, '', '', true );

		// Bind the provided identity to the just-created user
		openid_add_user_identity($user_id, $identity_url);

		openid_status('redirect');

		if ( !$user->has_cap('edit_posts') ) $redirect_to = '/wp-admin/profile.php';

	} else {
		// failed to create user for some reason.
		openid_message(__('OpenID authentication successful, but failed to create WordPress user. This is probably a bug.', 'openid'));
		openid_status('error');
		openid_error(openid_message());
	}

}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:63,代码来源:common.php

示例11: vp_do_signup

/**
 * Do signup a user.
 *
 * @since 0.0.1
 */
function vp_do_signup()
{
    if (!isset($_POST['action']) || 'vp_signup' != $_POST['action']) {
        return;
    }
    if (isset($_POST['vp_user_login']) && wp_verify_nonce($_POST['vp_signup_nonce'], 'vp-signup-nonce')) {
        $user_login = $_POST['vp_user_login'];
        $user_email = $_POST['vp_user_email'];
        $user_pwd = $_POST['vp_user_password'];
        $pwd_confirm = $_POST['vp_user_password_confirmation'];
        // Username already taken
        if (username_exists($user_login)) {
            vp_errors()->add('username_unavailable', __('Username already taken', 'v2press'));
        }
        // Username invalid
        if (!validate_username($user_login)) {
            vp_errors()->add('username_invalid', __('Invalid username', 'v2press'));
        }
        // Empty username
        if (empty($user_login)) {
            vp_errors()->add('username_empty', __('Please enter a username', 'v2press'));
        }
        // Username out range (4-12)
        if (!empty($user_login) && (4 > strlen($user_login) || 12 < strlen($user_login))) {
            vp_errors()->add('username_out_range', __('Username length must within 4-12 characters', 'v2press'));
        }
        // Empty email
        if (empty($user_email)) {
            vp_errors()->add('email_empty', __('Please enter your Email', 'v2press'));
        }
        // Invalid email
        if (!empty($user_email) && !is_email($user_email)) {
            vp_errors()->add('email_invalid', __('Invalid email', 'v2press'));
        }
        // Email address already registered
        if (!empty($user_email) && email_exists($user_email)) {
            vp_errors()->add('email_used', __('This Email already registered', 'v2press'));
        }
        // Empty password
        if (empty($user_pwd)) {
            vp_errors()->add('password_empty', __('Please enter a password', 'v2press'));
        }
        // Password not match
        if ($user_pwd != $pwd_confirm) {
            vp_errors()->add('password_mismatch', __('Passwords do not match', 'v2press'));
        }
        // reCAPTCHA error
        require_once VP_LIBS_PATH . '/recaptchalib.php';
        $privatekey = "6LeIKM0SAAAAAHe216bBiA8qWyDOgvIcCifUysM7";
        $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
            vp_errors()->add('recaptcha-error', __('reCAPATCH is not right.', 'v2press'));
        }
        $errors = vp_errors()->get_error_messages();
        // only create the user if there are no errors
        if (empty($errors)) {
            $new_user_id = wp_insert_user(array('user_login' => $user_login, 'user_pass' => $user_pwd, 'user_email' => $user_email, 'user_registered' => date('Y-m-d H:i:s'), 'role' => 'author'));
            if ($new_user_id) {
                // send an email to the admin alerting them of the registration
                wp_new_user_notification($new_user_id);
                // log the new user in
                wp_setcookie($user_login, $user_pwd, true);
                wp_set_current_user($new_user_id, $user_login);
                do_action('wp_login', $user_login);
                // send the newly created user to the home page after logging them in
                wp_redirect(home_url());
                exit;
            }
        }
        // END if empty $errors
    }
    // END if isset( $_POST['vp_user_login']
}
开发者ID:nacheal,项目名称:V2Press,代码行数:78,代码来源:member.php

示例12: tja_new_user

/**
 * TT New User
 * Creates a new user with args passed through an array or string of arguments. Passing arguments works the same
 * as functions such as query_posts(). Params are show as variable names which you must use when passing args
 * NOTE: wp_nonce_field( 'register' ) must be used on the register form
 *
 * @Param: username [string] - The desired username for the new user
 * @Param: email [string] - The desired email address for the new user
 * @Param: use_password [bool] [default: false] - Whether to specify a password on registration
 * @Param: password [string] - If use_password is true, the desired password for the new user
 * @Param: use_tos [bool] [default: true] - Whether the user needs to accept Terms of Service
 * @Param: tos [string] - If use_tos is true, the value to the accept Terms of Service checkbox
 * @Param: unique_email [bool] [default: false] - Set to true if only one username is allowed per email address
 * @Param: do_redirect [bool] [default: true] Whether to redirect the user after registration is complete
 * @Param: redirect [string] [default: User Profile Page] - The url to redirect the user to after successful login
 * @Param: send_email [bool] [default: true] Whether to send an email containing the username and password of the newly registered user
 * @Param: profile_info [array] [dafault: false] An array containing values to be used in wp_update_user() such as first_name, last_name
 * @Param: validate [bool] [default: true]
 * @param: require_verify_email [bool] [default: false] Sends the user an email with a Activate Account link to activate their account
 * @param: override_nonce [bool] [default: false] Bypasses the nonce check, not recommended in most situations
 * @return: The ID of the newly registered user [on error returns error string]
 * @author: Joe Hoyle
 * @version 1.0
 **/
function tja_new_user($args)
{
    //Check the nonce field
    if ($args['override_nonce'] !== true) {
        check_admin_referer('register');
    }
    if (is_user_logged_in()) {
        tj_error_message('You are already logged in', 'register');
        return new WP_Error('already-logged-in');
    }
    include_once ABSPATH . '/wp-includes/registration.php';
    $checks = array('use_password' => false, 'tos' => '', 'use_tos' => true, 'unique_email' => false, 'do_redirect' => true, 'redirect' => '', 'send_email' => false);
    $defaults = array('user_login' => '', 'user_email' => '', 'user_pass' => false, 'role' => 'subscriber', 'validate' => true);
    $original_args = $args;
    $default_args = array_merge($defaults, $checks);
    //Strip any tags then may have been put into the array
    strip_tags((string) $args);
    $args = wp_parse_args($args, $default_args);
    extract($args, EXTR_SKIP);
    $validation = apply_filters('tja_registration_info', $args);
    unset($args['user_pass2']);
    unset($user_pass2);
    if ($validation['status'] === 'error' && $validate == true) {
        return $validation;
    }
    // Merge arrays overwritting defaults, remove any non-standard keys keys with empty values.
    $user_vars = array_filter(array_intersect_key(array_merge($defaults, $args), $defaults));
    //Check for require_verify_email, send email and store temp data
    if ($require_verify_email) {
        $original_args['require_verify_email'] = false;
        $unverified_users = (array) get_option('unverified_users');
        $unverified_users[time()] = $original_args;
        update_option('unverified_users', $unverified_users);
        $message = "Please click the link below to activate your account for " . get_bloginfo() . "\n \n";
        $message .= '<a href="' . get_bloginfo('url') . '/login/?verify_email=' . $user_vars['user_email'] . '&key=' . time() . '">' . get_bloginfo('url') . '/login/?verify_email=' . $user_vars['user_email'] . '&key=' . time() . '</a>';
        $headers = 'From: ' . get_bloginfo() . ' <noreply@' . get_bloginfo('url') . '>' . "\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n\r\n";
        wp_mail($user_vars['user_email'], 'Please activate your account for ' . get_bloginfo(), $message, $headers);
        return tj_return_success('sent-email-activation', '<p class="message success">You have been sent an activation email, please follow the link in the email sent to ' . $user_vars['user_email'] . '</p>');
    }
    $user_id = wp_insert_user($user_vars);
    if ($role) {
        $user = new WP_User($user_id);
        $user->set_role($role);
    }
    // Get any remaining variable that were passed
    $meta_vars = array_diff_key($original_args, $defaults, $checks);
    foreach ((array) $meta_vars as $key => $value) {
        update_usermeta($user_id, $key, $value);
    }
    $user = get_userdata($user_id);
    //Send Notifcation email if specified
    if ($send_email == true) {
        $email = tja_email_registration_success($user, $user_pass);
    }
    //If they chose a password, login them in
    if ($use_password == 'true' && $user->ID > 0) {
        wp_login($user->user_login, $user_pass);
        wp_clearcookie();
        wp_setcookie($user->user_login, $user_pass, false);
    }
    //Redirect the user if is set
    if ($redirect !== '' && $user->ID && $do_redirect == true) {
        wp_redirect($redirect);
    }
    return $user_id;
}
开发者ID:adamcarlile,项目名称:Alex-Goy,代码行数:91,代码来源:tj-accounts.functions.php

示例13: ob_start

<?php

ob_start();
include_once '../../../wp-config.php';
include_once '../../../wp-load.php';
if ($_REQUEST['email'] && $_REQUEST['password']) {
    $email = $_REQUEST['email'];
    $password = $_REQUEST['password'];
    $username = $_REQUEST['username'];
    if (isset($_REQUEST['rememberme']) && $_REQUEST['rememberme'] == 1) {
        $secure_cookie = true;
    } else {
        $secure_cookie = false;
    }
    if (!username_exists($username) and email_exists($email) == false) {
        $user_id = wp_create_user($username, $_REQUEST['password'], $_REQUEST['email']);
        wp_update_user(array('ID' => $user_id, 'role' => 'author'));
        update_user_meta($user_id, 'show_admin_bar_front', 'false');
        $creds = array();
        $creds['user_login'] = $username;
        $creds['user_password'] = $_REQUEST['password'];
        $user = wp_signon($creds, $secure_cookie);
        wp_setcookie($username, $password, true);
        wp_set_current_user($user->data->ID, $username);
        echo "1";
        die;
    } else {
        echo "0";
        die;
    }
}
开发者ID:domalexxx,项目名称:nashvancouver,代码行数:31,代码来源:user_register.php

示例14: leaky_paywall_process_free_registration

 function leaky_paywall_process_free_registration()
 {
     if (isset($_POST['leaky_paywall_user_login']) && wp_verify_nonce($_POST['leaky_paywall_register_nonce'], 'leaky_paywall-register-nonce')) {
         $user_login = $_POST['leaky_paywall_user_login'];
         $user_email = $_POST['leaky_paywall_user_email'];
         $user_first = $_POST['leaky_paywall_user_first'];
         $user_last = $_POST['leaky_paywall_user_last'];
         $user_pass = $_POST['leaky_paywall_user_pass'];
         $pass_confirm = $_POST['leaky_paywall_user_pass_confirm'];
         $level_id = $_POST['leaky_paywall_register_level_id'];
         // this is required for username checks
         require_once ABSPATH . WPINC . '/user.php';
         $settings = get_leaky_paywall_settings();
         $return = '';
         if ($level = get_leaky_paywall_subscription_level($level_id)) {
             if (!empty($level['price'])) {
                 leaky_paywall_errors()->add('subscriptoin_level_not_free', __('Requested subscription level is not free', 'issuem-leaky-paywall'));
             }
         } else {
             leaky_paywall_errors()->add('invalid_subscription_level', __('Not a valid subscription level', 'issuem-leaky-paywall'));
         }
         if (username_exists($user_login)) {
             // Username already registered
             leaky_paywall_errors()->add('username_unavailable', __('Username already taken', 'issuem-leaky-paywall'));
         }
         if (!validate_username($user_login)) {
             // invalid username
             leaky_paywall_errors()->add('username_invalid', __('Invalid username', 'issuem-leaky-paywall'));
         }
         if (empty($user_login)) {
             // empty username
             leaky_paywall_errors()->add('username_empty', __('Please enter a username', 'issuem-leaky-paywall'));
         }
         if (!is_email($user_email)) {
             //invalid email
             leaky_paywall_errors()->add('email_invalid', __('Invalid email', 'issuem-leaky-paywall'));
         }
         if (email_exists($user_email)) {
             //Email address already registered
             leaky_paywall_errors()->add('email_used', __('Email already registered', 'issuem-leaky-paywall'));
         }
         if ($user_pass == '') {
             // passwords do not match
             leaky_paywall_errors()->add('password_empty', __('Please enter a password', 'issuem-leaky-paywall'));
         }
         if ($user_pass != $pass_confirm) {
             // passwords do not match
             leaky_paywall_errors()->add('password_mismatch', __('Passwords do not match', 'issuem-leaky-paywall'));
         }
         $errors = leaky_paywall_errors()->get_error_messages();
         // only create the user in if there are no errors
         if (empty($errors)) {
             $userdata = array('user_login' => $user_login, 'user_pass' => $user_pass, 'user_email' => $user_email, 'first_name' => $user_first, 'last_name' => $user_last, 'user_registered' => date_i18n('Y-m-d H:i:s'));
             $userdata = apply_filters('leaky_paywall_userdata_before_user_create', $userdata);
             $user_id = wp_insert_user($userdata);
             if ($user_id) {
                 leaky_paywall_email_subscription_status($user_id, 'new', $userdata);
                 $args = array('level_id' => $level_id, 'subscriber_id' => '', 'subscriber_email' => $user_email, 'price' => $level['price'], 'description' => $level['label'], 'payment_gateway' => 'free_registration', 'payment_status' => 'active', 'interval' => $level['interval'], 'interval_count' => $level['interval_count']);
                 if (isset($level['site'])) {
                     $args['site'] = $level['site'];
                 }
                 //Mimic PayPal's Plan...
                 if (!empty($level['recurring']) && 'on' == $level['recurring']) {
                     $args['plan'] = $level['interval_count'] . ' ' . strtoupper(substr($level['interval'], 0, 1));
                 }
                 $args['subscriber_email'] = $user_email;
                 leaky_paywall_update_subscriber(NULL, $user_email, 'free-' . time(), $args);
                 do_action('leaky_paywall_after_free_user_created', $user_id, $_POST);
                 // log the new user in
                 wp_setcookie($user_login, $user_pass, true);
                 wp_set_current_user($user_id, $user_login);
                 do_action('wp_login', $user_login);
                 // send the newly created user to the appropriate page after logging them in
                 if (!empty($settings['page_for_after_subscribe'])) {
                     wp_safe_redirect(get_page_link($settings['page_for_after_subscribe']));
                 } else {
                     if (!empty($settings['page_for_profile'])) {
                         wp_safe_redirect(get_page_link($settings['page_for_profile']));
                     } else {
                         if (!empty($settings['page_for_subscription'])) {
                             wp_safe_redirect(get_page_link($settings['page_for_subscription']));
                         }
                     }
                 }
                 exit;
             }
         }
     }
 }
开发者ID:zeen101,项目名称:leaky-paywall,代码行数:89,代码来源:deprecated.php

示例15: wp_hash_password

				
			if ($password1 != '') {
				if ($password1 == $password2) {
					$pwd = wp_hash_password($password1);
					$sql = "UPDATE ".$wpdb->base_prefix."users SET user_pass = '%s' WHERE ID = %d";
				    if ($wpdb->query( $wpdb->prepare($sql, $pwd, $uid) ) ) {
	
	
						$sql = "SELECT user_login FROM ".$wpdb->base_prefix."users WHERE ID = %d";
						$username = $wpdb->get_var($wpdb->prepare($sql, $uid));

						$id = $uid;
						$url = __wps__get_url('profile')."?view=settings&msg=".$pwmsg;
	
				    	wp_login($username, $pwd, true);
				        wp_setcookie($username, $pwd, true);
				        wp_set_current_user($id, $username);
			    	
						$pwmsg = "PASSWORD CHANGED";										
					
				    } else {
				    	$pwmsg = __("Failed to update password, sorry.", WPS_TEXT_DOMAIN);
				    }
				} else {
			    	$pwmsg = __("Passwords different, please try again.", WPS_TEXT_DOMAIN);
				}
			}
			
			echo $pwmsg;
			
		} else {
开发者ID:niamherinoc,项目名称:rctractors,代码行数:30,代码来源:profile_functions.php


注:本文中的wp_setcookie函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。