本文整理汇总了PHP中wp_hash_password函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_hash_password函数的具体用法?PHP wp_hash_password怎么用?PHP wp_hash_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_hash_password函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: scramble_password
private function scramble_password()
{
if ($this->options['scramble_passwords'] && $this->new_user == false) {
$this->user->user_pass = wp_hash_password(wp_generate_password(12, true, true));
wp_update_user($user);
}
}
开发者ID:justinoue,项目名称:SSOPress,代码行数:7,代码来源:sso.php
示例2: value
static function value($new, $old, $post_id, $field)
{
if ($new != $old) {
return wp_hash_password(parent::value($new, $old, $post_id, $field));
} else {
return parent::value($new, $old, $post_id, $field);
}
}
开发者ID:tamalsarker,项目名称:meta-box,代码行数:8,代码来源:password.php
示例3: wp_set_password
/**
* Set password using bcrypt
*
* @param string $password Plaintext password
* @param int $userId ID of user to whom password belongs
* @return bool|string
*/
function wp_set_password($password, $userId)
{
/** @var \wpdb $wpdb */
global $wpdb;
$hash = wp_hash_password($password);
$wpdb->update($wpdb->users, ['user_pass' => $hash, 'user_activation_key' => ''], ['ID' => $userId]);
wp_cache_delete($userId, 'users');
return $hash;
}
开发者ID:roots,项目名称:wp-password-bcrypt,代码行数:16,代码来源:wp-password-bcrypt.php
示例4: test_wp_hash_password_trimming
/**
* Test wp_hash_password trims whitespace
*
* This is similar to test_password_trimming but tests the "lower level"
* wp_hash_password function
*
* @ticket 24973
*/
function test_wp_hash_password_trimming()
{
$password = ' pass with leading whitespace';
$this->assertTrue(wp_check_password('pass with leading whitespace', wp_hash_password($password)));
$password = 'pass with trailing whitespace ';
$this->assertTrue(wp_check_password('pass with trailing whitespace', wp_hash_password($password)));
$password = ' pass with whitespace ';
$this->assertTrue(wp_check_password('pass with whitespace', wp_hash_password($password)));
$password = "pass with new line \n";
$this->assertTrue(wp_check_password('pass with new line', wp_hash_password($password)));
$password = "pass with vertial tab o_O\v";
$this->assertTrue(wp_check_password('pass with vertial tab o_O', wp_hash_password($password)));
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:21,代码来源:auth.php
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::$db_needed = true;
parent::set_up_before_class();
if (extension_loaded('mbstring')) {
self::$pass_1 = self::USER_PASS;
} else {
self::$pass_1 = 'Some ASCII Only PW 4 You!';
}
self::$pass_2 = '!AJd81aasjk2@';
self::$hash_1 = wp_hash_password(self::$pass_1);
self::$hash_2 = wp_hash_password(self::$pass_2);
}
开发者ID:kaos-addict,项目名称:trad,代码行数:13,代码来源:PasswordChangeTest.php
示例6: signup
function signup()
{
require_once WPPR_PLUGIN_DIR . '/models/signup-model.php';
$model = new Signup_Model();
$username = sanitize_user($this->username);
$email = sanitize_email($this->email);
$password = $this->password;
$activation_key = generate_key($email);
$userdata = array($username, $email, wp_hash_password($password), $activation_key, CUR_DATE, REMOTE_IP);
if (is_wp_error($this->validate_signup())) {
$attributes['errors'] = $this->validate_signup()->get_error_message();
} else {
$result = $model->insert_signup($userdata);
if (!is_wp_error($result)) {
$attributes['success'] = 'Please check your email for confirmation';
//send email confirmation to user
$this->send_activation_link($username, $email, $password, $activation_key);
} else {
$attributes['errors'] = 'Something went wrong. Please try again later';
}
}
return $attributes;
}
开发者ID:owliber,项目名称:pr-membership,代码行数:23,代码来源:pr-signup-controller.php
示例7: bp_core_screen_signup
//.........这里部分代码省略.........
}
/**
* Fires after the validation of a new signup.
*
* @since BuddyPress (1.1.0)
*/
do_action('bp_signup_validate');
// Add any errors to the action for the field in the template for display.
if (!empty($bp->signup->errors)) {
foreach ((array) $bp->signup->errors as $fieldname => $error_message) {
// addslashes() and stripslashes() to avoid create_function()
// syntax errors when the $error_message contains quotes
/**
* Filters the error message in the loop.
*
* @since BuddyPress (1.5.0)
*
* @param string $value Error message wrapped in html.
*/
add_action('bp_' . $fieldname . '_errors', create_function('', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\\"error\\">" . stripslashes( \'' . addslashes($error_message) . '\' ) . "</div>" );'));
}
} else {
$bp->signup->step = 'save-details';
// No errors! Let's register those deets.
$active_signup = !empty($bp->site_options['registration']) ? $bp->site_options['registration'] : '';
if ('none' != $active_signup) {
// Make sure the extended profiles module is enabled
if (bp_is_active('xprofile')) {
// Let's compact any profile field info into usermeta
$profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
// Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile()
foreach ((array) $profile_field_ids as $field_id) {
if (!isset($_POST['field_' . $field_id])) {
if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
// Concatenate the values
$date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
// Turn the concatenated value into a timestamp
$_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
}
}
if (!empty($_POST['field_' . $field_id])) {
$usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
}
if (!empty($_POST['field_' . $field_id . '_visibility'])) {
$usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
}
}
// Store the profile field ID's in usermeta
$usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
}
// Hash and store the password
$usermeta['password'] = wp_hash_password($_POST['signup_password']);
// If the user decided to create a blog, save those details to usermeta
if ('blog' == $active_signup || 'all' == $active_signup) {
$usermeta['public'] = isset($_POST['signup_blog_privacy']) && 'public' == $_POST['signup_blog_privacy'] ? true : false;
}
/**
* Filters the user meta used for signup.
*
* @since BuddyPress (1.1.0)
*
* @param array $usermeta Array of user meta to add to signup.
*/
$usermeta = apply_filters('bp_signup_usermeta', $usermeta);
// Finally, sign up the user and/or blog
if (isset($_POST['signup_with_blog']) && is_multisite()) {
$wp_user_id = bp_core_signup_blog($blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta);
} else {
$wp_user_id = bp_core_signup_user($_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta);
}
if (is_wp_error($wp_user_id)) {
$bp->signup->step = 'request-details';
bp_core_add_message($wp_user_id->get_error_message(), 'error');
} else {
$bp->signup->step = 'completed-confirmation';
}
}
/**
* Fires after the completion of a new signup.
*
* @since BuddyPress (1.1.0)
*/
do_action('bp_complete_signup');
}
}
/**
* Fires right before the loading of the Member registration screen template file.
*
* @since BuddyPress (1.5.0)
*/
do_action('bp_core_screen_signup');
/**
* Filters the template to load for the Member registration page screen.
*
* @since BuddyPress (1.5.0)
*
* @param string $value Path to the Member registration template to load.
*/
bp_core_load_template(apply_filters('bp_core_template_register', array('register', 'registration/register')));
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:101,代码来源:bp-members-screens.php
示例8: wpmem_a_activate_user
/**
* Activates a user
*
* If registration is moderated, sets the activated flag
* in the usermeta. Flag prevents login when WPMEM_MOD_REG
* is true (1). Function is fired from bulk user edit or
* user profile update.
*
* @since 2.4
*
* @param int $user_id
* @param bool $chk_pass
* @uses $wpdb WordPress Database object
*/
function wpmem_a_activate_user($user_id, $chk_pass = false)
{
// define new_pass
$new_pass = '';
// If passwords are user defined skip this
if (!$chk_pass) {
// generates a password to send the user
$new_pass = wp_generate_password();
$new_hash = wp_hash_password($new_pass);
// update the user with the new password
global $wpdb;
$wpdb->update($wpdb->users, array('user_pass' => $new_hash), array('ID' => $user_id), array('%s'), array('%d'));
}
// if subscriptions can expire, set the user's expiration date
if (WPMEM_USE_EXP == 1) {
wpmem_set_exp($user_id);
}
// generate and send user approved email to user
require_once WPMEM_PATH . 'wp-members-email.php';
wpmem_inc_regemail($user_id, $new_pass, 2);
// set the active flag in usermeta
update_user_meta($user_id, 'active', 1);
/**
* Fires after the user activation process is complete.
*
* @since 2.8.2
*
* @param int $user_id The user's ID.
*/
do_action('wpmem_user_activated', $user_id);
return;
}
开发者ID:GaryJones,项目名称:gobrenix.com,代码行数:46,代码来源:users.php
示例9: wp_update_user
/**
* Update an user in the database.
*
* It is possible to update a user's password by specifying the 'user_pass'
* value in the $userdata parameter array.
*
* If $userdata does not contain an 'ID' key, then a new user will be created
* and the new user's ID will be returned.
*
* If current user's password is being updated, then the cookies will be
* cleared.
*
* @since 2.0.0
* @see wp_insert_user() For what fields can be set in $userdata
* @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already
*
* @param array $userdata An array of user data.
* @return int The updated user's ID.
*/
function wp_update_user($userdata)
{
$ID = (int) $userdata['ID'];
// First, get all of the original fields
$user_obj = get_userdata($ID);
$user = get_object_vars($user_obj->data);
// Add additional custom fields
foreach (_get_additional_user_keys($user_obj) as $key) {
$user[$key] = get_user_meta($ID, $key, true);
}
// Escape data pulled from DB.
$user = add_magic_quotes($user);
// If password is changing, hash it now.
if (!empty($userdata['user_pass'])) {
$plaintext_pass = $userdata['user_pass'];
$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
}
wp_cache_delete($user['user_email'], 'useremail');
// Merge old and new fields with new fields overwriting old ones.
$userdata = array_merge($user, $userdata);
$user_id = wp_insert_user($userdata);
// Update the cookies if the password changed.
$current_user = wp_get_current_user();
if ($current_user->ID == $ID) {
if (isset($plaintext_pass)) {
wp_clear_auth_cookie();
wp_set_auth_cookie($ID);
}
}
return $user_id;
}
开发者ID:prostart,项目名称:cobblestonepath,代码行数:50,代码来源:user.php
示例10: create_new_application_password
/**
* Generate a new application password.
*
* @since 0.1-dev
*
* @access public
* @static
*
* @param int $user_id User ID.
* @param string $name Password name.
* @return array The first key in the array is the new password, the second is its row in the table.
*/
public static function create_new_application_password($user_id, $name)
{
$new_password = wp_generate_password(16, false);
$hashed_password = wp_hash_password($new_password);
$new_item = array('name' => $name, 'password' => $hashed_password, 'created' => time(), 'last_used' => null, 'last_ip' => null);
$passwords = self::get_user_application_passwords($user_id);
if (!$passwords) {
$passwords = array();
}
$passwords[] = $new_item;
self::set_user_application_passwords($user_id, $passwords);
return array($new_password, $new_item);
}
开发者ID:arshidkv12,项目名称:application-passwords,代码行数:25,代码来源:class.application-passwords.php
示例11: wp_set_password
/**
* Updates the user's password with a new encrypted one.
*
* For integration with other applications, this function can be overwritten to
* instead use the other package password checking algorithm.
*
* @since 2.5
* @uses $wpdb WordPress database object for queries
* @uses wp_hash_password() Used to encrypt the user's password before passing to the database
*
* @param string $password The plaintext new user password
* @param int $user_id User ID
*/
function wp_set_password($password, $user_id)
{
global $wpdb;
$hash = wp_hash_password($password);
$query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $hash, $user_id);
$wpdb->query($query);
wp_cache_delete($user_id, 'users');
}
开发者ID:nurpax,项目名称:saastafi,代码行数:21,代码来源:pluggable.php
示例12: queue_user
function queue_user($user_login, $user_pass, $user_email, $user_meta = '')
{
$sql = "INSERT INTO {$this->user_queue} (user_login, user_pass, user_email, user_timestamp, user_meta) VALUES ";
$sql .= $this->db->prepare("( %s, %s, %s, %d, %s )", $user_login, wp_hash_password($user_pass), $user_email, time(), serialize($user_meta));
$sql .= $this->db->prepare(" ON DUPLICATE KEY UPDATE user_timestamp = %d", time());
if ($this->db->query($sql)) {
return $this->db->insert_id;
} else {
return new WP_Error('queueerror', __('Could not create your user account.', 'membership'));
}
}
开发者ID:EdoMagen,项目名称:project-s-v2,代码行数:11,代码来源:membershippublic.php
示例13: wppb_register_user
function wppb_register_user($global_request, $userdata)
{
$wppb_general_settings = get_option('wppb_general_settings');
$user_id = null;
$new_user_signup = false;
if (isset($wppb_general_settings['loginWith']) && $wppb_general_settings['loginWith'] == 'email') {
$userdata['user_login'] = apply_filters('wppb_generated_random_username', Wordpress_Creation_Kit_PB::wck_generate_slug(trim($userdata['user_email'])), $userdata['user_email']);
}
if (isset($wppb_general_settings['emailConfirmation']) && $wppb_general_settings['emailConfirmation'] == 'yes') {
$new_user_signup = true;
$userdata = $this->wppb_add_custom_field_values($global_request, $userdata, $this->args['form_fields']);
if (!isset($userdata['role'])) {
$userdata['role'] = $this->args['role'];
} else {
if (isset($wppb_module_settings['wppb_customRedirect']) && $wppb_module_settings['wppb_customRedirect'] == 'show' && function_exists('wppb_custom_redirect_url')) {
$this->args['redirect_url'] = wppb_custom_redirect_url('after_registration', $this->args['redirect_url'], $userdata["user_login"], $userdata['role']);
}
}
$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
if (is_multisite()) {
/* since version 2.0.7 add this meta so we know on what blog the user registered */
$userdata['registered_for_blog_id'] = get_current_blog_id();
$userdata = wp_unslash($userdata);
}
wppb_signup_user($userdata['user_login'], $userdata['user_email'], $userdata);
} else {
if (!isset($userdata['role'])) {
$userdata['role'] = $this->args['role'];
} else {
if (isset($wppb_module_settings['wppb_customRedirect']) && $wppb_module_settings['wppb_customRedirect'] == 'show' && function_exists('wppb_custom_redirect_url')) {
$this->args['redirect_url'] = wppb_custom_redirect_url('after_registration', $this->args['redirect_url'], $userdata["user_login"], $userdata['role']);
}
}
$userdata = wp_unslash($userdata);
// change User Registered date and time according to timezone selected in WordPress settings
$wppb_get_date = wppb_get_date_by_timezone();
if (isset($wppb_get_date)) {
$userdata['user_registered'] = $wppb_get_date;
}
// insert user to database
$user_id = wp_insert_user($userdata);
}
return array('userdata' => $userdata, 'user_id' => $user_id, 'new_user_signup' => $new_user_signup);
}
开发者ID:alvarpoon,项目名称:aeg,代码行数:44,代码来源:class-formbuilder.php
示例14: purchase
/**
* Generates a Purchase record from the order
*
* @since 1.1
*
* @return void
**/
function purchase () {
global $Ecart;
// Need a transaction ID to create a purchase
if (empty($this->txnid)) return false;
// Lock for concurrency protection
$this->lock();
$Purchase = new Purchase($this->txnid,'txnid');
if (!empty($Purchase->id)) {
$this->unlock();
$Ecart->resession();
$this->purchase = $Purchase->id;
if ($this->purchase !== false)
ecart_redirect(ecarturl(false,'thanks'));
}
// WordPress account integration used, customer has no wp user
if ("wordpress" == $this->accounts && empty($this->Customer->wpuser)) {
if ( $wpuser = get_current_user_id() ) $this->Customer->wpuser = $wpuser; // use logged in WordPress account
else $this->Customer->create_wpuser(); // not logged in, create new account
}
// New customer, save hashed password
if (!$this->Customer->exists() && !empty($this->Customer->password)) {
$this->Customer->id = false;
if (ECART_DEBUG) new EcartError('Creating new Ecart customer record','new_customer',ECART_DEBUG_ERR);
if ("ecart" == $this->accounts) $this->Customer->notification();
$this->Customer->password = wp_hash_password($this->Customer->password);
} else unset($this->Customer->password); // Existing customer, do not overwrite password field!
$this->Customer->save();
$this->Billing->customer = $this->Customer->id;
$this->Billing->card = substr($this->Billing->card,-4);
$paycard = Lookup::paycard($this->Billing->cardtype);
$this->Billing->cardtype = !$paycard?$this->Billing->cardtype:$paycard->name;
$this->Billing->cvv = false;
$this->Billing->save();
// Card data is truncated, switch the cart to normal mode
$Ecart->Shopping->secured(false);
if (!empty($this->Shipping->address)) {
$this->Shipping->customer = $this->Customer->id;
$this->Shipping->save();
}
$base = $Ecart->Settings->get('base_operations');
$promos = array();
foreach ($this->Cart->discounts as &$promo) {
$promos[$promo->id] = $promo->name;
$promo->uses++;
}
$Purchase = new Purchase();
$Purchase->copydata($this);
$Purchase->copydata($this->Customer);
$Purchase->copydata($this->Billing);
$Purchase->copydata($this->Shipping,'ship');
$Purchase->copydata($this->Cart->Totals);
$Purchase->customer = $this->Customer->id;
$Purchase->billing = $this->Billing->id;
$Purchase->shipping = $this->Shipping->id;
$Purchase->taxing = ($base['vat'])?'inclusive':'exclusive';
$Purchase->promos = $promos;
$Purchase->freight = $this->Cart->Totals->shipping;
$Purchase->ip = $Ecart->Shopping->ip;
$Purchase->save();
$this->unlock();
Promotion::used(array_keys($promos));
foreach($this->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->price = $Item->option->id;
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) $Purchased->keygen();
$Purchased->save();
if ($Item->inventory) $Item->unstock();
}
$this->purchase = $Purchase->id;
$Ecart->Purchase = &$Purchase;
if (ECART_DEBUG) new EcartError('Purchase '.$Purchase->id.' was successfully saved to the database.',false,ECART_DEBUG_ERR);
do_action('ecart_order_notifications');
//.........这里部分代码省略.........
开发者ID:robbiespire,项目名称:paQui,代码行数:101,代码来源:Order.php
示例15: value
/**
* Store secured password in the database.
* @param mixed $new
* @param mixed $old
* @param int $post_id
* @param array $field
* @return string
*/
static function value($new, $old, $post_id, $field)
{
$new = $new != $old ? wp_hash_password($new) : $new;
return $new;
}
开发者ID:warfare-plugins,项目名称:social-warfare,代码行数:13,代码来源:password.php
示例16: process
public static function process()
{
// We have to avoid truthiness, hence the strange logic expression
if (true !== apply_filters('shopp_validate_registration', true)) {
return;
}
$Customer = ShoppOrder()->Customer;
do_action('shopp_customer_registration', $Customer);
if ($Customer->session(ShoppCustomer::GUEST)) {
$Customer->type = __('Guest', 'Shopp');
// No cuts
$Customer->wpuser = 0;
// No buts
unset($Customer->password);
// No coconuts
} else {
// WordPress account integration used, customer has no wp user
if ('wordpress' == shopp_setting('account_system') && empty($Customer->wpuser)) {
if ($wpuser = get_current_user_id()) {
$Customer->wpuser = $wpuser;
} else {
$Customer->create_wpuser();
}
// not logged in, create new account
}
if (!$Customer->exists(true)) {
$Customer->id = false;
shopp_debug('Creating new Shopp customer record');
if (empty($Customer->password)) {
$Customer->password = wp_generate_password(12, true);
}
if ('shopp' == shopp_setting('account_system')) {
$Customer->notification();
}
$Customer->password = wp_hash_password($Customer->password);
if (isset($Customer->passhash)) {
$Customer->password = $Customer->passhash;
}
} else {
unset($Customer->password);
}
// Existing customer, do not overwrite password field!
}
// New customer, save hashed password
$Customer->save();
$Customer->password = '';
// Update billing and shipping addresses
$addresses = array('Billing', 'Shipping');
foreach ($addresses as $Address) {
if (empty(ShoppOrder()->{$Address}->address)) {
continue;
}
$Address = ShoppOrder()->{$Address};
$Address->customer = $Customer->id;
$Address->save();
}
do_action('shopp_customer_registered', $Customer);
// Auto-login
$Customer->login();
// Login the customer
if (!empty($Customer->wpuser)) {
// Log the WordPress user in
ShoppLogin::wpuser(get_user_by('id', $Customer->wpuser));
}
if (apply_filters('shopp_registration_redirect', false)) {
Shopp::redirect(Shopp::url(false, 'account'));
}
}
开发者ID:msigley,项目名称:shopp,代码行数:68,代码来源:Registration.php
示例17: do_process
function do_process()
{
$action = strtolower(ym_request('Action'));
if (!ym_get('ZombaioGWPass')) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed.</h3>No pass';
exit;
}
$gw_pass = ym_get('ZombaioGWPass');
if ($gw_pass != $this->gw_pass) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed.</h3>Mismatch';
exit;
}
if (!$this->verify_ipn_ip()) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed, you are not Zombaio.</h3>';
exit;
}
// test hit from zombaio
$test = substr(ym_request('username'), 0, 4);
if ($test == 'Test' && !ym_request('extra')) {
// test mode
echo 'OK';
exit;
}
// verify site ID, first catch user.add/delete second credits
$site_id = ym_request('SITE_ID', ym_request('SiteID'));
if ($site_id && $site_id != $this->site_id) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed.</h3>site id';
exit;
}
// verify price ID exists
$data = ym_request('extra');
$complete = FALSE;
switch ($action) {
case 'user.add':
$complete = TRUE;
list($buy, $subscription, $pack_id, $user_id) = explode('_', $data);
if ($this->use_password && ym_get('password')) {
// use password
$user_pass = wp_hash_password(ym_get('password'));
global $wpdb;
$query = 'UPDATE ' . $wpdb->users . ' SET user_pass = \'' . $user_pass . '\' WHERE ID = \'' . $user_id . '\'';
$wpdb->query($query);
}
// store SUBSCRIPTION_ID
$subscription_id = ym_get('SUBSCRIPTION_ID');
update_user_meta($user_id, 'ym_zombaio_subscription_id', $subscription_id);
break;
case 'rebill':
// renewal
$subscription_id = ym_get('SUBSCRIPTION_ID');
if (!$subscription_id) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>Missing Subscription ID.</h3>';
exit;
}
//get user ID by subscription ID
global $wpdb;
$query = 'SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE meta_key = \'ym_zombaio_subscription_id\' AND meta_value = \'' . $subscription_id . '\'';
$user_id = $wpdb->get_var($query);
if (!$user_id) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>User Not Known.</h3>';
exit;
}
$success = ym_request('Success', 0);
// 0 FAIL 2 FAIL retry in 5 days
if ($success == 1) {
$complete = TRUE;
}
$data = new YourMember_User($user_id);
$pack_id = $data->pack_id;
$data = 'buy_subscription_' . $pack_id . '_' . $user_id;
break;
case 'user.delete':
$user = get_user_by('username', ym_get('username'));
if (!$user) {
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Zombaio Gateway 1.1</h1><h3>User Not Known.</h3>';
exit;
}
$user_id = $user->ID;
$data = new YourMember_User($user_id);
$pack_id = $data->pack_id;
$data = 'end_subscription_' . $pack_id . '_' . $user_id;
break;
case 'user.addcredits':
$complete = FALSE;
// no support
$data = 'buy_credits_1_1';
}
$this->common_process($data, $this->code, $complete, FALSE);
echo 'OK';
exit;
}
开发者ID:AdultStack,项目名称:ap-members,代码行数:98,代码来源:ym_zombaio.php
示例18: wp_update_user
/**
* Update an user in the database.
*
* It is possible to update a user's password by specifying the 'user_pass'
* value in the $userdata parameter array.
*
* If current user's password is being updated, then the cookies will be
* cleared.
*
* @since 2.0.0
*
* @see wp_insert_user() For what fields can be set in $userdata.
*
* @param mixed $userdata An array of user data or a user object of type stdClass or WP_User.
* @return int|WP_Error The updated user's ID or a WP_Error object if the user could not be updated.
*/
function wp_update_user($userdata)
{
if (is_a($userdata, 'stdClass')) {
$userdata = get_object_vars($userdata);
} elseif (is_a($userdata, 'WP_User')) {
$userdata = $userdata->to_array();
}
$ID = (int) $userdata['ID'];
// First, get all of the original fields
$user_obj = get_userdata($ID);
if (!$user_obj) {
return new WP_Error('invalid_user_id', __('Invalid user ID.'));
}
$user = $user_obj->to_array();
// Add additional custom fields
foreach (_get_additional_user_keys($user_obj) as $key) {
$user[$key] = get_user_meta($ID, $key, true);
}
// Escape data pulled from DB.
$user = add_magic_quotes($user);
// If password is changing, hash it now.
if (!empty($userdata['user_pass'])) {
$plaintext_pass = $userdata['user_pass'];
$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
}
wp_cache_delete($user['user_email'], 'useremail');
// Merge old and new fields with new fields overwriting old ones.
$userdata = array_merge($user, $userdata);
$user_id = wp_insert_user($userdata);
// Update the cookies if the password changed.
$current_user = wp_get_current_user();
if ($current_user->ID == $ID) {
if (isset($plaintext_pass)) {
wp_clear_auth_cookie();
// Here we calculate the expiration length of the current auth cookie and compare it to the default expiration.
// If it's greater than this, then we know the user checked 'Remember Me' when they logged in.
$logged_in_cookie = wp_parse_auth_cookie('', 'logged_in');
/** This filter is documented in wp-includes/pluggable.php */
$default_cookie_life = apply_filters('auth_cookie_expiration', 2 * DAY_IN_SECONDS, $ID, false);
$remember = $logged_in_cookie['expiration'] - time() > $default_cookie_life;
wp_set_auth_cookie($ID, $remember);
}
}
return $user_id;
}
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:61,代码来源:user.php
示例19: new_fb_login_action
function new_fb_login_action()
{
global $wp, $wpdb, $new_fb_settings;
if (isset($_GET['action']) && $_GET['action'] == 'unlink') {
$user_info = wp_get_current_user();
if ($user_info->ID) {
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'social_users
WHERE ID = %d
AND type = \'fb\'', $user_info->ID));
set_site_transient($user_info->ID . '_new_fb_admin_notice', __('Your Facebook profile is successfully unlinked from your account.', 'nextend-facebook-connect'), 3600);
}
new_fb_redirect();
}
require_once dirname(__FILE__) . '/sdk/init.php';
$user = $facebook->getUser();
if ($user && is_user_logged_in() && new_fb_is_user_connected()) {
new_fb_redirect();
} elseif ($user) {
// Register or Login
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me', 'GET', array('fields' => 'id,name,email,first_name,last_name'));
$ID = $wpdb->get_var($wpdb->prepare('
SELECT ID FROM ' . $wpdb->prefix . 'social_users WHERE type = "fb" AND identifier = "%d"
', $user_profile['id']));
if (!get_user_by('id', $ID)) {
$wpdb->query($wpdb->prepare('
DELETE FROM ' . $wpdb->prefix . 'social_users WHERE ID = "%d"
', $ID));
$ID = null;
}
if (!is_user_logged_in()) {
if ($ID == NULL) {
// Register
if (!isset($user_profile['email'])) {
$user_profile['email'] = $user_profile['id'] . '@facebook.com';
}
$ID = email_exists($user_profile['email']);
if ($ID == false) {
// Real register
require_once ABSPATH . WPINC . '/registration.php';
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
if (!isset($new_fb_settings['fb_user_prefix'])) {
$new_fb_settings['fb_user_prefix'] = 'facebook-';
}
$username = strtolower($user_profile['first_name'] . $user_profile['last_name']);
$sanitized_user_login = sanitize_user($new_fb_settings['fb_user_prefix'] . $username);
if (!validate_username($sanitized_user_login)) {
$sanitized_user_login = sanitize_user('facebook' . $user_profile['id']);
}
$defaul_user_name = $sanitized_user_login;
$i = 1;
while (username_exists($sanitized_user_login)) {
$sanitized_user_login = $defaul_user_name . $i;
$i++;
}
// $ID = wp_create_user($sanitized_user_login, $random_password, $user_profile['email']);
// $ID = wp_create_user($user_profile['email'], $random_password, $user_profile['email']);
$wpdb->insert($wpdb->users, array('user_login' => $user_profile['email'], 'user_pass' => wp_hash_password($random_password), 'user_email' => $user_profile['email'], 'user_registered' => current_time('mysql')), array('%s', '%s', '%s', '%s'));
$ID = $wpdb->insert_id;
if (!is_wp_error($ID)) {
// wp_new_user_notification($ID, $random_password);
$to = $user_profile['email'];
$subject = 'Tài khoản của bạn đã được xác thực';
$body = 'Chào ' . $user_profile['name'] . '<br/>
Việc đăng ký trên Myclass.vn đã được xác thực. Sau đây là thông tin tài khoản của bạn: <br /><br />
Tên đăng nhập: ' . $user_profile['email'] . ' <br/>
Mật khẩu: ' . $random_password . '<br/><br />
Bạn hãy đăng nhập vào itclass.vn để tham gia các khóa học Lập Trình tốt nhất, mang tính thực tiễn cao của chúng tôi. <br />
Thân mến <br />
<a href="http://itclass.vn">Myclass.vn</a>';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail($to, $subject, $body, $headers);
$user_info = get_userdata($ID);
wp_update_user(array('ID' => $ID, 'display_name' => $user_profile['name'], 'user_nicename' => $sanitized_user_login, 'first_name' => $user_profile['first_name'], 'last_name' => $user_profile['last_name']));
//update_user_meta( $ID, 'new_fb_default_password', $user_info->user_pass);
do_action('nextend_fb_user_registered', $ID, $user_profile, $facebook);
} else {
return;
}
}
if ($ID) {
$wpdb->insert($wpdb->prefix . 'social_users', array('ID' => $ID, 'type' => 'fb', 'identifier' => $user_profile['id']), array('%d', '%s', '%s'));
}
if (isset($new_fb_settings['fb_redirect_reg']) && $new_fb_settings['fb_redirect_reg'] != '' && $new_fb_settings['fb_redirect_reg'] != 'auto') {
set_site_transient(nextend_uniqid() . '_fb_r', $new_fb_settings['fb_redirect_reg'], 3600);
}
}
if ($ID) {
// Login
$secure_cookie = is_ssl();
$secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, array());
global $auth_secure_cookie;
// XXX ugly hack to pass this to wp_authenticate_cookie
$auth_secure_cookie = $secure_cookie;
wp_set_auth_cookie($ID, true, $secure_cookie);
$user_info = get_userdata($ID);
update_user_meta($ID, 'fb_profile_picture', 'https://graph.facebook.com/' . $user_profile['id'] . '/picture?type=large');
do_action('wp_login', $user_info->user_login, $user_info);
update_user_meta($ID, 'fb_user_access_token', $facebook->getAccessToken());
//.........这里部分代码省略.........
开发者ID:songlequang,项目名称:myclass,代码行数:101,代码来源:nextend-facebook-connect.php
|
请发表评论