本文整理汇总了PHP中wp_generate_password函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_generate_password函数的具体用法?PHP wp_generate_password怎么用?PHP wp_generate_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_generate_password函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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";
}
}
示例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);
}
示例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;
}
}
示例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';
}
}
}
示例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);
}
示例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);
}
示例11: kopa_shortcode_tabs
/**
*
*
* @package Kopa
* @subpackage Core
* @author thethangtran <tranthethang@gmail.com>
* @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);
}
示例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);
}
示例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 ) );
}
示例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;
}
示例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;
}