本文整理汇总了PHP中wp_generate_password函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_generate_password函数的具体用法?PHP wp_generate_password怎么用?PHP wp_generate_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_generate_password函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: subscribe
function subscribe()
{
global $videotube;
$name = wp_filter_nohtml_kses($_POST['name']);
$email = wp_filter_nohtml_kses($_POST['email']);
$agree = wp_filter_nohtml_kses($_POST['agree']);
$referer = wp_filter_nohtml_kses($_POST['referer']);
$role = isset($videotube['subscribe_roles']) ? $videotube['subscribe_roles'] : 'subscriber';
if (!$name) {
echo json_encode(array('resp' => 'error', 'message' => __('Please enter your name.', 'mars'), 'id' => 'name'));
exit;
}
if (!$email || !is_email($email)) {
echo json_encode(array('resp' => 'error', 'message' => __('Please enter a valid email address.', 'mars'), 'id' => 'email'));
exit;
}
if ($agree != true || $agree != 'true') {
echo json_encode(array('resp' => 'error', 'message' => __('Please agree with our Private Policy.', 'mars'), 'id' => 'agree'));
exit;
}
$user_id = wp_insert_user(array('user_login' => $email, 'user_email' => $email, 'display_name' => $name, 'user_pass' => wp_generate_password(6, true), 'role' => $role));
if (is_wp_error($user_id)) {
echo json_encode(array('resp' => 'error', 'message' => $user_id->get_error_message()));
exit;
}
update_user_meta($user_id, 'referer', $referer);
echo json_encode(array('resp' => 'success', 'message' => __('Congratulation.', 'mars'), 'redirect_to' => get_permalink($referer)));
exit;
}
开发者ID:chypriote,项目名称:wp-video,代码行数:29,代码来源:Mars_Subscribe_Ajax.php
示例2: start
public function start()
{
global $current_user;
wp_get_current_user();
// By default, users to skip:
// * Super admins (Automattic employees visiting your site)
// * Users who don't have /wp-admin/ access
$is_privileged_user = !is_proxied_automattician() && current_user_can('edit_posts');
if (false === apply_filters('ndn_run_for_current_user', $is_privileged_user)) {
return;
}
// Set up the per-blog salt
$salt = get_option('newdevicenotification_salt');
if (!$salt) {
$salt = wp_generate_password(64, true, true);
add_option('newdevicenotification_salt', $salt);
}
$this->cookie_hash = hash_hmac('md5', $current_user->ID, $salt);
// Seen this device before?
if ($this->verify_cookie()) {
return;
}
// Attempt to mark this device as seen via a cookie
$this->set_cookie();
// Maybe we've seen this user+IP+agent before but they don't accept cookies?
$memcached_key = 'lastseen_' . $current_user->ID . '_' . md5($_SERVER['REMOTE_ADDR'] . '|' . $_SERVER['HTTP_USER_AGENT']);
if (wp_cache_get($memcached_key, 'newdevicenotification')) {
return;
}
// As a backup to the cookie, record this IP address (only in memcached for now, proper logging will come later)
wp_cache_set($memcached_key, time(), 'newdevicenotification');
add_filter('ndn_send_email', array($this, 'maybe_send_email'), 10, 2);
$this->notify_of_new_device();
}
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:34,代码来源:new-device-notification.php
示例3: wp_new_user_notification
function wp_new_user_notification($user_id, $plaintext_pass = '')
{
global $pagenow;
global $register_plus_redux;
//trigger_error( sprintf( __( 'Register Plus Redux DEBUG: wp_new_user_notification($user_id=%s, $plaintext_pass=%s) from %s', 'register-plus-redux' ), $user_id, $plaintext_pass, $pagenow ) );
if ('1' === $register_plus_redux->rpr_get_option('user_set_password') && !empty($_POST['pass1'])) {
$plaintext_pass = stripslashes((string) $_POST['pass1']);
}
if ('user-new.php' === $pagenow && !empty($_POST['pass1'])) {
$plaintext_pass = stripslashes((string) $_POST['pass1']);
}
//TODO: Code now only forces users registering to verify email, may want to add settings to have admin created users verify email too
$verification_code = '';
if ('wp-login.php' === $pagenow && '1' === $register_plus_redux->rpr_get_option('verify_user_email')) {
$verification_code = wp_generate_password(20, FALSE);
update_user_meta($user_id, 'email_verification_code', $verification_code);
update_user_meta($user_id, 'email_verification_sent', gmdate('Y-m-d H:i:s'));
$register_plus_redux->send_verification_mail($user_id, $verification_code);
}
if ('wp-login.php' === $pagenow && '1' !== $register_plus_redux->rpr_get_option('disable_user_message_registered') || 'wp-login.php' !== $pagenow && '1' !== $register_plus_redux->rpr_get_option('disable_user_message_created')) {
if ('1' !== $register_plus_redux->rpr_get_option('verify_user_email') && '1' !== $register_plus_redux->rpr_get_option('verify_user_admin')) {
$register_plus_redux->send_welcome_user_mail($user_id, $plaintext_pass);
}
}
if ('wp-login.php' === $pagenow && '1' !== $register_plus_redux->rpr_get_option('disable_admin_message_registered') || 'wp-login.php' !== $pagenow && '1' !== $register_plus_redux->rpr_get_option('disable_admin_message_created')) {
$register_plus_redux->send_admin_mail($user_id, $plaintext_pass, $verification_code);
}
}
开发者ID:alvarpoon,项目名称:anbig,代码行数:28,代码来源:rpr-new-user-notification.php
示例4: handle_on_expire_user_reset_password
/**
* Generate random password when user expires?
*/
function handle_on_expire_user_reset_password($expired_user)
{
if ($expired_user->on_expire_user_reset_password) {
$password = wp_generate_password(12, false);
wp_set_password($password, $expired_user->user_id);
}
}
开发者ID:abhijagtap73,项目名称:expire-users,代码行数:10,代码来源:expire-users.php
示例5: acxu_createUser
function acxu_createUser($args)
{
global $wp_xmlrpc_server;
$wp_xmlrpc_server->escape($args);
$nickname = $args[0];
//$password = $args[1];
//if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) )
// return $wp_xmlrpc_server->error;
$user_name = time() . "_" . rand(1000, 9999);
$user_email = $user_name . "@bbuser.org";
if (!username_exists($user_name) && !email_exists($user_email)) {
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
$user_id = wp_create_user($user_name, $random_password, $user_email);
if ($nickname == "") {
$nickname = $user_email;
}
// Update the user to set the nickname
wp_update_user(array('ID' => $user_id, 'nickname' => $nickname));
// Get the user object to set the user's role
$wp_user_object = new WP_User($user_id);
//http://en.support.wordpress.com/user-roles/
$wp_user_object->set_role('author');
return $user_name . " " . $random_password;
} else {
return "ERROR: User Name or Email Already Exists";
}
}
开发者ID:AurangZ,项目名称:securereader,代码行数:27,代码来源:auto-create-xmlrpc-user.php
示例6: create
/**
* Creates a patchchat post by
* creating a user,
* creating a new patchchat post,
* creating first comment to post,
* adding an 'instant reply' comment from admin,
* building a new transient,
* return new transient to new user
*
* @author caseypatrickdriscoll
*
* @edited 2015-08-03 16:32:16 - Adds user signon after creation
* @edited 2015-08-28 20:11:39 - Adds PatchChat_Settings::instant_reply
* @edited 2015-08-28 20:19:22 - Adds PatchChat_Settings::bot
*/
public static function create($patchchat)
{
$email = $patchchat['email'];
$text = $patchchat['text'];
$username = substr($email, 0, strpos($email, "@"));
$password = wp_generate_password(10, false);
$title = substr($text, 0, 40);
$time = current_time('mysql');
$text = wp_strip_all_tags($text);
/* Create User */
$user_id = wp_create_user($username, $password, $email);
// TODO: Add the user's name to the user
// TODO: Check to see if user logged in, no need to create again
wp_new_user_notification($user_id, $password);
$user = get_user_by('id', $user_id);
$creds = array('user_login' => $user->user_login, 'user_password' => $password, 'remember' => true);
$user_signon = wp_signon($creds, false);
/* Create PatchChat Post */
$post = array('post_title' => $title, 'post_type' => 'patchchat', 'post_author' => $user_id, 'post_status' => 'new', 'post_date' => $time);
$post_id = wp_insert_post($post);
/* Create First Comment */
$comment = array('comment_post_ID' => $post_id, 'user_id' => $user_id, 'comment_content' => $text, 'comment_date' => $time, 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_agent' => $_SERVER['HTTP_USER_AGENT']);
$comment_id = wp_insert_comment($comment);
/* Insert default action comment reply */
$options = array('chatid' => $post_id, 'displayname' => $user->display_name);
$comment = array('comment_post_ID' => $post_id, 'user_id' => PatchChat_Settings::bot(), 'comment_content' => PatchChat_Settings::instant_reply($options), 'comment_type' => 'auto', 'comment_date' => current_time('mysql'));
$comment_id = wp_insert_comment($comment);
// Will build the Transient
PatchChat_Transient::get($post_id);
return PatchChat_Controller::get_user_state($user_id);
}
开发者ID:patchdotworks,项目名称:patchchat,代码行数:46,代码来源:class-patchchat-controller.php
示例7: wppb_curpageurl_password_recovery2
function wppb_curpageurl_password_recovery2($user_login, $id)
{
global $wpdb;
$pageURL = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
$questionPos = strpos((string) $pageURL, '?');
$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM {$wpdb->users} WHERE user_login = %s", $user_login));
if (empty($key)) {
// Generate something random for a key...
$key = wp_generate_password(20, false);
do_action('wppb_retrieve_password_key', $user_login, $key);
// Now insert the new md5 key into the db
$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
}
//$key = md5($user_login.'RMPBP'.$id.'PWRCVR');
if ($questionPos !== false) {
//$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
return $pageURL . '&loginName=' . $user_login . '&key=' . $key;
} else {
//$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
return $pageURL . '?loginName=' . $user_login . '&key=' . $key;
}
}
开发者ID:par-orillonsoft,项目名称:elearning-wordpress,代码行数:31,代码来源:wppb.recover.password.php
示例8: seed_cspv4_emaillist_followupemails_queue_email
function seed_cspv4_emaillist_followupemails_queue_email()
{
global $wpdb, $seed_cspv4, $seed_cspv4_post_result;
extract($seed_cspv4);
require_once SEED_CSPV4_PLUGIN_PATH . 'lib/nameparse.php';
$name = '';
if (!empty($_REQUEST['name'])) {
$name = $_REQUEST['name'];
}
$email = strtolower($_REQUEST['email']);
$fname = '';
$lname = '';
if (!empty($name)) {
$name = seed_cspv4_parse_name($name);
$fname = $name['first'];
$lname = $name['last'];
}
if (email_exists($email)) {
// Subscriber already exist show stats
$seed_cspv4_post_result['status'] = '200';
$seed_cspv4_post_result['msg'] = $txt_already_subscribed_msg;
$seed_cspv4_post_result['msg_class'] = 'alert-info';
$seed_cspv4_post_result['clicks'] = '0';
} else {
$user_id = wp_insert_user(array('user_login' => $email, 'user_email' => $email, 'first_name' => $fname, 'last_name' => $lname, 'user_pass' => wp_generate_password()));
if (empty($seed_cspv4_post_result['status'])) {
$seed_cspv4_post_result['status'] = '200';
}
}
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:30,代码来源:followupemails.php
示例9: custom_new_user_notification
function custom_new_user_notification($user_id, $deprecated = null, $notify = '', $password = null)
{
if ($deprecated !== null) {
_deprecated_argument(__FUNCTION__, '4.3.1');
}
global $wpdb, $wp_hasher;
$user = get_userdata($user_id);
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
$message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
if ('admin' === $notify || empty($notify)) {
return;
}
if ($password === null) {
$password = wp_generate_password(12, false);
}
// change the URL below to actual page with [adverts_manage] shortcode.
$manage_url = home_url() . "/adverts/manage/";
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $password) . "\r\n";
$message .= 'To manage your Ads please use the following address ' . $manage_url . "\r\n";
wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
}
开发者ID:simpliko,项目名称:wpadverts-snippets,代码行数:27,代码来源:custom-registration-email.php
示例10: konzilo_auth_settings
function konzilo_auth_settings()
{
$state = get_option('konzilo_oauth_state', '');
if (empty($state)) {
$state = wp_generate_password(20, false);
update_option('konzilo_oauth_state', $state);
}
$client_id = get_option('konzilo_client_id');
$client_key = get_option('konzilo_client_key');
$url = KONZILO_URL;
$redirect_uri = admin_url('options-general.php?page=konzilo_auth_settings');
try {
if (konzilo_get_token($url, $client_id, $client_key, $redirect_uri, $state, true)) {
$message = __('Authorization complete', 'konzilo');
}
} catch (Exception $e) {
$error = $e->getMessage();
}
$args = array('client_id' => $client_id, 'client_key' => $client_key, 'authorized' => get_option('konzilo_refresh_token', false), 'error' => !empty($error) ? $error : false, 'message' => !empty($message) ? $message : false);
if (isset($_GET['client_id']) && isset($_GET['client_secret']) && empty($_GET['settings-updated'])) {
$args['client_id'] = $_GET['client_id'];
$args['client_key'] = $_GET['client_secret'];
$args['from_konzilo'] = TRUE;
}
if (!empty($client_id)) {
$args['link'] = $url . '/oauth2/authorize?response_type=code&client_id=' . urlencode($client_id) . '&redirect_uri=' . urlencode($redirect_uri) . '&scope=users&state=' . $state;
}
$base_dir = plugin_dir_path(__FILE__);
echo konzilo_twig($base_dir)->render('templates/auth_form.html', $args);
}
开发者ID:konzilo,项目名称:konzilo-wp,代码行数:30,代码来源:konzilo.pages.php
示例11: kopa_shortcode_tabs
/**
*
*
* @package Kopa
* @subpackage Core
* @author thethangtran <[email protected]>
* @since 1.0.0
*
*/
function kopa_shortcode_tabs($atts, $content = null)
{
extract(shortcode_atts(array('style' => 'horizontal', 'width' => 200), $atts));
$style = !empty($atts['style']) && in_array($atts['style'], array('horizontal', 'vertical')) ? $atts['style'] : 'horizontal';
$width = '';
if ('vertical' == $style) {
$width = !empty($atts['width']) ? (int) $atts['width'] : 200;
$width = sprintf('style="width:%spx;"', $width > 0 ? $width : 200);
}
$items = KopaUtil::get_shortcode($content, true, array('tab'));
$navs = array();
$panels = array();
if ($items) {
$active = 'active';
foreach ($items as $item) {
$title = $item['atts']['title'];
$item_id = 'tab-' . wp_generate_password(4, false, false);
$navs[] = sprintf('<li><a href="#%s">%s</a></li>', $item_id, do_shortcode($title));
$panels[] = sprintf('<div id="%s">%s</div>', $item_id, do_shortcode($item['content']));
$active = '';
}
}
$output = sprintf('<div class="kp-tabs tab-%s">', $style);
$output .= sprintf('<ul %s>', $width);
$output .= implode('', $navs);
$output .= '</ul>';
$output .= implode('', $panels);
$output .= '</div>';
return apply_filters('kopa_shortcode_tabs', $output);
}
开发者ID:dgordon86,项目名称:breakbiodark,代码行数:39,代码来源:tabs.php
示例12: general
function general()
{
echo '<h3>' . __('BP Social Connect Settings', 'bp-social-connect') . '</h3>';
$settings = array(array('label' => __('Redirect Settings', 'vibe-customtypes'), 'name' => 'redirect_link', 'type' => 'select', 'options' => apply_filters('bp_social_connect_redirect_settings', array('' => __('Same Page', 'vibe-customtypes'), 'home' => __('Home', 'vibe-customtypes'), 'profile' => __('BuddyPress Profile', 'vibe-customtypes'))), 'desc' => __('Set Login redirect settings', 'vibe-customtypes')), array('label' => __('Security Key', 'vibe-customtypes'), 'name' => 'security', 'type' => 'text', 'std' => wp_generate_password(16, false), 'desc' => __('Set a random security key value', 'vibe-customtypes')), array('label' => __('Social Button Styling', 'vibe-customtypes'), 'name' => 'button_css', 'type' => 'textarea', 'std' => '
.bp_social_connect{
text-align: center;
}
.bp_social_connect a {
background: #3b5998;
color: #FFF;
font-weight: 600;
padding: 15px 20px;
display: inline-block;
text-decoration: none;
min-width: 220px;
margin: 5px 0;
border-radius: 2px;
letter-spacing: 1px;
box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}
.bp_social_connect a:hover{
box-shadow: none;
}
.bp_social_connect a:focus{
box-shadow: inset 0 4px 0 rgba(0,0,0,0.1)
}
#bp_social_connect_twitter{
background:#4099FF;
}
#bp_social_connect_google{
background:#DD4B39;
}', 'desc' => __('Change default style of buttons', 'vibe-customtypes')));
$this->generate_form('general', $settings);
}
开发者ID:nikitansk,项目名称:devschool,代码行数:34,代码来源:class.settings.php
示例13: woo_cd_create_options
function woo_cd_create_options() {
$prefix = 'woo_ce';
if( !get_option( $prefix . '_export_filename' ) )
add_option( $prefix . '_export_filename', 'export_%dataset%-%date%-%time%.csv' );
if( !get_option( $prefix . '_delete_file' ) )
add_option( $prefix . '_delete_file', 1 );
if( !get_option( $prefix . '_delimiter' ) )
add_option( $prefix . '_delimiter', ',' );
if( !get_option( $prefix . '_category_separator' ) )
add_option( $prefix . '_category_separator', '|' );
if( !get_option( $prefix . '_bom' ) )
add_option( $prefix . '_bom', 1 );
if( !get_option( $prefix . '_encoding' ) )
add_option( $prefix . '_encoding', get_option( 'blog_charset', 'UTF-8' ) );
if( !get_option( $prefix . '_escape_formatting' ) )
add_option( $prefix . '_escape_formatting', 'all' );
if( !get_option( $prefix . '_date_format' ) )
add_option( $prefix . '_date_format', 'd/m/Y' );
// Generate a unique CRON secret key for each new installation
if( !get_option( $prefix . '_secret_key' ) )
add_option( $prefix . '_secret_key', wp_generate_password( 64, false ) );
}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:26,代码来源:install.php
示例14: ucenter_oauth
function ucenter_oauth()
{
//根据授权码获取access_token
$url = UCENTER_API . '/oauth/accessToken';
$data = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'grant_type' => 'authorization_code', 'redirect_uri' => REDIRECT_URI, 'code' => $_GET['code']);
$response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
$data = json_decode($response['body'], true);
if (1 !== $data['code']) {
wp_die('授权失败');
}
$access_token = $data['data']['access_token'];
//根据access_token获取用户信息
$url = UCENTER_API . '/user/?access_token=' . $access_token;
$data = wp_remote_get($url);
$data = json_decode($data['body'], true);
if (1 !== $data['code']) {
wp_die('获取用户信息失败');
}
$username = $data['data']['username'];
$user_id = $data['data']['user_id'];
//根据返回的用户信息登录,用户还未存在时则插入
$current_user = get_user_by('login', $username);
if (is_wp_error($current_user) || !$current_user) {
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
$user_id = wp_insert_user(array('user_login' => $username, 'display_name' => $username, 'nick_name' => $username, 'user_pass' => $random_password));
wp_set_auth_cookie($user_id);
} else {
wp_set_auth_cookie($current_user->ID);
}
header('Location: ' . home_url() . '/wp-admin');
exit;
}
开发者ID:yaoshanliang,项目名称:WordPress,代码行数:32,代码来源:wp-ucenter-login.php
示例15: retrieve_password
/**
* Handles sending password retrieval email to user.
*
* @uses $wpdb WordPress Database object
*
* @return bool|WP_Error True: when finish. WP_Error on error
*/
function retrieve_password()
{
global $wpdb;
$errors = new WP_Error();
if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
}
if (strpos($_POST['user_login'], '@')) {
$user_data = get_user_by_email(trim($_POST['user_login']));
if (empty($user_data)) {
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
}
} else {
$login = trim($_POST['user_login']);
$user_data = get_userdatabylogin($login);
}
do_action('lostpassword_post');
if ($errors->get_error_code()) {
return $errors;
}
if (!$user_data) {
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
return $errors;
}
// redefining user_login ensures we return the right case in the email
$user_login = $user_data->user_login;
$user_email = $user_data->user_email;
do_action('retreive_password', $user_login);
// Misspelled and deprecated
do_action('retrieve_password', $user_login);
$allow = apply_filters('allow_password_reset', true, $user_data->ID);
if (!$allow) {
return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
} else {
if (is_wp_error($allow)) {
return $allow;
}
}
$user_email = $_POST['user_email'];
$user_login = $_POST['user_login'];
$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_login = %s", $user_login));
if (empty($user)) {
return new WP_Error('invalid_key', __('Invalid key'));
}
$new_pass = wp_generate_password(12, false);
do_action('password_reset', $user, $new_pass);
wp_set_password($new_pass, $user->ID);
update_usermeta($user->ID, 'default_password_nag', true);
//Set up the Password change nag.
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
$message .= site_url() . '/?ptype=affiliate' . "\r\n";
$title = sprintf(__('[%s] Your new password'), get_option('blogname'));
$title = apply_filters('password_reset_title', $title);
$message = apply_filters('password_reset_message', $message, $new_pass);
if ($message && !wp_mail($user_email, $title, $message)) {
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
}
return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:67,代码来源:affiliate_login.php
示例16: wp_new_user_notification
function wp_new_user_notification($user_id, $deprecated = null, $notify = '')
{
if ($deprecated !== null) {
_deprecated_argument(__FUNCTION__, '4.3.1');
}
// `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notifcation.
if ('admin' === $notify || empty($deprecated) && empty($notify)) {
return;
}
global $wpdb, $wp_hasher;
$user = get_userdata($user_id);
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
// Generate something random for a password reset key.
$key = wp_generate_password(20, false);
/** This action is documented in wp-login.php */
do_action('retrieve_password_key', $user->user_login, $key);
// Now insert the key, hashed, into the DB.
if (empty($wp_hasher)) {
require_once ABSPATH . WPINC . '/class-phpass.php';
$wp_hasher = new PasswordHash(8, true);
}
$hashed = time() . ':' . $wp_hasher->HashPassword($key);
$wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login));
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
$message .= __('To set your password, visit the following address:') . "\r\n\r\n";
$message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
$message .= wp_login_url() . "\r\n";
wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
}
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:31,代码来源:cwwp-disable-new-user-emails.php
示例17: checkauthor
function checkauthor($author) {
global $wpdb;
//mtnames is an array with the names in the mt import file
$pass = wp_generate_password();
if (!(in_array($author, $this->mtnames))) { //a new mt author name is found
++ $this->j;
$this->mtnames[$this->j] = $author; //add that new mt author name to an array
$user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user
if (!$user_id) { //banging my head against the desk now.
if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
$user_id = wp_create_user($author, $pass);
$this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank.
} else {
$user_id = wp_create_user($this->newauthornames[$this->j], $pass);
}
} else {
return $user_id; // return pre-existing wp username if it exists
}
} else {
$key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array
$user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames
}
return $user_id;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:25,代码来源:mt.php
示例18: get_new_salts
public static function get_new_salts()
{
// From wp-admin/setup-config.php in WordPress 4.5.
// Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password().
try {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
$max = strlen($chars) - 1;
for ($i = 0; $i < 8; $i++) {
$key = '';
for ($j = 0; $j < 64; $j++) {
$key .= substr($chars, random_int(0, $max), 1);
}
$secret_keys[] = $key;
}
} catch (Exception $ex) {
$secret_keys = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/');
if (is_wp_error($secret_keys)) {
$secret_keys = array();
for ($i = 0; $i < 8; $i++) {
$secret_keys[] = wp_generate_password(64, true, true);
}
} else {
$secret_keys = explode("\n", wp_remote_retrieve_body($secret_keys));
foreach ($secret_keys as $k => $v) {
$secret_keys[$k] = substr($v, 28, 64);
}
}
}
return $secret_keys;
}
开发者ID:Garth619,项目名称:Femi9,代码行数:30,代码来源:utilities.php
示例19: sfw_new_comment_pass
function sfw_new_comment_pass()
{
global $post;
$new_comment_pwd = wp_generate_password(12, false);
$old_password = get_post_meta($post->ID, 'sfw_pwd', true);
update_post_meta($post->ID, 'sfw_pwd', $new_comment_pwd, $old_password);
}
开发者ID:bryanmonzon,项目名称:jenjonesdirect,代码行数:7,代码来源:functions.php
示例20: user_register
public function user_register()
{
global $wpdb;
$data = $_POST;
$login_data = array();
$resp = new ajax_response($data['action'], true);
$code_data = $wpdb->get_results('SELECT * FROM ' . $wpdb->register_codes . ' WHERE 1=1 AND register_code == ' . $wpdb->escape($data['sec_code']));
if ($code_data->register_code_used == 0) {
$username = $wpdb->escape($data['user_name']);
$exists = username_exists($username);
if (!$exists) {
$user_id = wp_create_user($username, wp_generate_password($length = 12, $include_standard_special_chars = false), $username);
wp_new_user_notification($user_id, null, true);
if (!is_wp_error($user_id)) {
$user = get_user_by('id', $user_id);
$wpdb->update($wpdb->register_codes, array('register_code_used' => 1, 'register_code_used_by' => $user->data->user_login), array('register_code' => $wpdb->escape($data['sec_code'])));
$resp->set_status(true);
$resp->set_message($user->data->user_login . ' is successfully registered. Please switch to the login tab to login.');
} else {
foreach ($user_id->errors as $k => $error) {
$resp->set_message(array($error[0]));
}
}
} else {
$resp->set_message('User already exists. Please use a different email address.');
}
} else {
$resp->set_message('Security token not recognized. Could not register you without a valid security token.');
}
echo $resp->encode_response();
die;
}
开发者ID:TrevorMW,项目名称:wp-lrsgen,代码行数:32,代码来源:class-custom-login.php
注:本文中的wp_generate_password函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论