本文整理汇总了PHP中_wp_get_user_contactmethods函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_get_user_contactmethods函数的具体用法?PHP _wp_get_user_contactmethods怎么用?PHP _wp_get_user_contactmethods使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_wp_get_user_contactmethods函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: marketify_entry_author_social
/**
* Social Links
*
* @since Marketify 1.0
*
* @return void
*/
function marketify_entry_author_social($user_id = null)
{
global $post;
$methods = _wp_get_user_contactmethods();
$social = array();
if (!$user_id) {
$user_id = get_the_author_meta('ID');
}
foreach ($methods as $key => $method) {
$field = get_the_author_meta($key, $user_id);
if (!$field) {
continue;
}
$social[$key] = sprintf('<a href="%1$s" target="_blank"><i class="icon-%2$s"></i></a>', $field, $key);
}
$social = implode(' ', $social);
return $social;
}
示例2: __construct
/**
* Constructor
*
* $args contains 3 optional parameters, but at least 1 must be defined
* - user_id: load userdata by ID
* - user_login: load userdata by user_login
* - user_email: load userdata by user_email
*
* @param array $args
*/
public function __construct($args)
{
if (!empty($args['user_id'])) {
$this->user = new WP_User($args['user_id']);
} elseif (!empty($args['user_login'])) {
$u = get_user_by('login', $args['user_login']);
$this->user = new WP_User($u->ID);
unset($u);
} elseif (!empty($args['user_email'])) {
$u = get_user_by('email', $args['user_email']);
$this->user = new WP_User($u->ID);
unset($u);
}
if (empty($this->user)) {
throw new Exception(__('Could not start user', 'cf-deploy') . ': ' . print_r($args, true));
}
// add any additional profile fields as needed
foreach (_wp_get_user_contactmethods() as $contact_method => $contact_method_name) {
$this->profile_fields[$contact_method] = null;
}
}
示例3: _e
</tr>
<tr>
<th><label for="url"><?php
_e('Website', 'theme-my-login');
?>
</label></th>
<td><input type="text" name="url" id="url" value="<?php
echo esc_attr($profileuser->user_url);
?>
" class="regular-text code" /></td>
</tr>
<?php
if (function_exists('_wp_get_user_contactmethods')) {
foreach (_wp_get_user_contactmethods() as $name => $desc) {
?>
<tr>
<th><label for="<?php
echo $name;
?>
"><?php
echo apply_filters('user_' . $name . '_label', $desc);
?>
</label></th>
<td><input type="text" name="<?php
echo $name;
?>
" id="<?php
echo $name;
?>
示例4: wp_insert_user
//.........这里部分代码省略.........
if ( empty($user_email) )
$user_email = '';
$user_email = apply_filters('pre_user_email', $user_email);
if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) )
return new WP_Error('existing_user_email', __('This email address is already registered.') );
if ( empty($display_name) )
$display_name = $user_login;
$display_name = apply_filters('pre_user_display_name', $display_name);
if ( empty($nickname) )
$nickname = $user_login;
$nickname = apply_filters('pre_user_nickname', $nickname);
if ( empty($first_name) )
$first_name = '';
$first_name = apply_filters('pre_user_first_name', $first_name);
if ( empty($last_name) )
$last_name = '';
$last_name = apply_filters('pre_user_last_name', $last_name);
if ( empty($description) )
$description = '';
$description = apply_filters('pre_user_description', $description);
if ( empty($rich_editing) )
$rich_editing = 'true';
if ( empty($comment_shortcuts) )
$comment_shortcuts = 'false';
if ( empty($admin_color) )
$admin_color = 'fresh';
$admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
if ( empty($use_ssl) )
$use_ssl = 0;
if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s');
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
if ( $user_nicename_check ) {
$suffix = 2;
while ($user_nicename_check) {
$alt_user_nicename = $user_nicename . "-$suffix";
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
$suffix++;
}
$user_nicename = $alt_user_nicename;
}
$data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
$data = stripslashes_deep( $data );
if ( $update ) {
$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
$user_id = (int) $ID;
} else {
$wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
$user_id = (int) $wpdb->insert_id;
}
update_user_meta( $user_id, 'first_name', $first_name);
update_user_meta( $user_id, 'last_name', $last_name);
update_user_meta( $user_id, 'nickname', $nickname );
update_user_meta( $user_id, 'description', $description );
update_user_meta( $user_id, 'rich_editing', $rich_editing);
update_user_meta( $user_id, 'comment_shortcuts', $comment_shortcuts);
update_user_meta( $user_id, 'admin_color', $admin_color);
update_user_meta( $user_id, 'use_ssl', $use_ssl);
foreach ( _wp_get_user_contactmethods() as $method => $name ) {
if ( empty($$method) )
$$method = '';
update_user_meta( $user_id, $method, $$method );
}
if ( isset($role) ) {
$user = new WP_User($user_id);
$user->set_role($role);
} elseif ( !$update ) {
$user = new WP_User($user_id);
$user->set_role(get_option('default_role'));
}
wp_cache_delete($user_id, 'users');
wp_cache_delete($user_login, 'userlogins');
if ( $update )
do_action('profile_update', $user_id, $old_user_data);
else
do_action('user_register', $user_id);
return $user_id;
}
示例5: ym_user_profile_form
function ym_user_profile_form()
{
get_currentuserinfo();
global $current_user, $wpdb;
$updated = false;
$action = ym_post('ym_action');
if ($action == 'ym_user_profile_update') {
include 'wp-admin/includes/user.php';
include 'wp-includes/registration.php';
do_action('personal_options_update', $current_user->ID);
$errors = edit_user($current_user->ID);
if (!is_wp_error($errors)) {
$html = '<p>' . __('Your Profile has been updated') . '</p>';
$html .= '<meta http-equiv="refresh" content="3" />';
return $html;
}
}
$html = '';
if (isset($errors) && is_wp_error($errors)) {
$html .= '<div class="error"><p>' . implode("</p>\n<p>", $errors->get_error_messages()) . '</p></div>';
} else {
if (ym_get('updated')) {
$html .= '<div id="message" class="updated"><p><strong>' . __('User updated.') . '</strong></p></div>';
}
}
if (!function_exists(_wp_get_user_contactmethods)) {
function _wp_get_user_contactmethods()
{
$user_contactmethods = array('aim' => __('AIM'), 'yim' => __('Yahoo IM'), 'jabber' => __('Jabber / Google Talk'));
return apply_filters('user_contactmethods', $user_contactmethods);
}
}
$html .= '
<form action="" method="post">
<input type="hidden" name="ym_action" value="ym_user_profile_update" />
<table class="form-table">
<tr><td colspan="2"><h3>' . __('Name') . '</h3></td></tr>
<tr>
<th><label for="first_name">' . __('First Name') . '</label></th>
<td><input type="text" name="first_name" id="first_name" value="' . esc_attr($current_user->user_firstname) . '" class="regular-text" /></td>
</tr>
<tr>
<th><label for="last_name">' . __('Last Name') . '</label></th>
<td><input type="text" name="last_name" id="last_name" value="' . esc_attr($current_user->user_lastname) . '" class="regular-text" /></td>
</tr>
<tr>
<th><label for="nickname">' . __('Nickname') . ' <span class="description">' . __('(required)') . '</span></label></th>
<td><input type="text" name="nickname" id="nickname" value="' . esc_attr($current_user->nickname) . '" class="regular-text" /></td>
</tr>
<tr>
<th><label for="display_name">' . __('Display name publicly as') . '</label></th>
<td>
<select name="display_name" id="display_name">
';
$public_display = array();
$public_display['display_username'] = $current_user->user_login;
$public_display['display_nickname'] = $current_user->nickname;
if (!empty($profileuser->first_name)) {
$public_display['display_firstname'] = $current_user->first_name;
}
if (!empty($profileuser->last_name)) {
$public_display['display_lastname'] = $current_user->last_name;
}
if (!empty($profileuser->first_name) && !empty($current_user->last_name)) {
$public_display['display_firstlast'] = $current_user->first_name . ' ' . $current_user->last_name;
$public_display['display_lastfirst'] = $current_user->last_name . ' ' . $current_user->first_name;
}
if (!in_array($current_user->display_name, $public_display)) {
// Only add this if it isn't duplicated elsewhere
$public_display = array('display_displayname' => $current_user->display_name) + $public_display;
}
$public_display = array_map('trim', $public_display);
$public_display = array_unique($public_display);
foreach ($public_display as $id => $item) {
$html .= '<option id="' . $id . '" value="' . esc_attr($item) . '"' . selected($current_user->display_name, $item, FALSE) . '>' . $item . '</option>';
}
$html .= '
</select>
</td>
</tr>
<tr><td colspan="2">
<h3>' . __('Contact Info') . '</h3>
</td></tr>
<tr>
<th><label for="email">' . __('E-mail') . ' <span class="description">' . __('(required)') . '</span></label></th>
<td><input type="text" name="email" id="email" value="' . esc_attr($current_user->user_email) . '" class="regular-text" />
';
$new_email = get_option($current_user->ID . '_new_email');
if ($new_email && $new_email != $current_user->user_email) {
$html .= '
<div class="updated inline">
<p>' . sprintf(__('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url(admin_url('profile.php?dismiss=' . $current_user->ID . '_new_email'))) . '</p>
</div>
';
}
$html .= '
//.........这里部分代码省略.........
示例6: _e
</tr>
<tr>
<th><label for="description"><?php
_e('About Me:', APP_TD);
?>
</label></th>
<td><textarea name="description" class="regular-text" id="description" rows="10" cols="50"><?php
echo esc_textarea($current_user->description);
?>
</textarea></td>
</tr>
<?php
foreach (_wp_get_user_contactmethods($current_user) as $name => $desc) {
?>
<tr>
<th><label for="<?php
echo $name;
?>
"><?php
echo apply_filters('user_' . $name . '_label', $desc);
?>
:</label></th>
<td>
<input type="text" name="<?php
echo $name;
?>
" class="text regular-text" id="<?php
echo $name;
示例7: edit_user
/**
* Edit user settings based on contents of $_POST
*
* Used on user-edit.php and profile.php to manage and process user options, passwords etc.
*
* @since 2.0
*
* @param int $user_id Optional. User ID.
* @return int user id of the updated user
*/
function edit_user($user_id = 0)
{
global $wp_roles, $wpdb;
$user = new stdClass();
if ($user_id) {
$update = true;
$user->ID = (int) $user_id;
$userdata = get_userdata($user_id);
$user->user_login = $wpdb->escape($userdata->user_login);
} else {
$update = false;
}
if (!$update && isset($_POST['user_login'])) {
$user->user_login = sanitize_user($_POST['user_login'], true);
}
$pass1 = $pass2 = '';
if (isset($_POST['pass1'])) {
$pass1 = $_POST['pass1'];
}
if (isset($_POST['pass2'])) {
$pass2 = $_POST['pass2'];
}
if (isset($_POST['role']) && current_user_can('edit_users')) {
$new_role = sanitize_text_field($_POST['role']);
$potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false;
// Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
// Multisite super admins can freely edit their blog roles -- they possess all caps.
if (is_multisite() && current_user_can('manage_sites') || $user_id != get_current_user_id() || $potential_role && $potential_role->has_cap('edit_users')) {
$user->role = $new_role;
}
// If the new role isn't editable by the logged-in user die with error
$editable_roles = get_editable_roles();
if (!empty($new_role) && empty($editable_roles[$new_role])) {
wp_die(__('You can’t give users that role.'));
}
}
if (isset($_POST['email'])) {
$user->user_email = sanitize_text_field($_POST['email']);
}
if (isset($_POST['url'])) {
if (empty($_POST['url']) || $_POST['url'] == 'http://') {
$user->user_url = '';
} else {
$user->user_url = esc_url_raw($_POST['url']);
$user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url;
}
}
if (isset($_POST['first_name'])) {
$user->first_name = sanitize_text_field($_POST['first_name']);
}
if (isset($_POST['last_name'])) {
$user->last_name = sanitize_text_field($_POST['last_name']);
}
if (isset($_POST['nickname'])) {
$user->nickname = sanitize_text_field($_POST['nickname']);
}
if (isset($_POST['display_name'])) {
$user->display_name = sanitize_text_field($_POST['display_name']);
}
if (isset($_POST['description'])) {
$user->description = trim($_POST['description']);
}
foreach (_wp_get_user_contactmethods($user) as $method => $name) {
if (isset($_POST[$method])) {
$user->{$method} = sanitize_text_field($_POST[$method]);
}
}
if ($update) {
$user->rich_editing = isset($_POST['rich_editing']) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
$user->admin_color = isset($_POST['admin_color']) ? sanitize_text_field($_POST['admin_color']) : 'fresh';
$user->show_admin_bar_front = isset($_POST['admin_bar_front']) ? 'true' : 'false';
}
$user->comment_shortcuts = isset($_POST['comment_shortcuts']) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
$user->use_ssl = 0;
if (!empty($_POST['use_ssl'])) {
$user->use_ssl = 1;
}
$errors = new WP_Error();
/* checking that username has been typed */
if ($user->user_login == '') {
$errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
}
/* checking the password has been typed twice */
do_action_ref_array('check_passwords', array($user->user_login, &$pass1, &$pass2));
if ($update) {
if (empty($pass1) && !empty($pass2)) {
$errors->add('pass', __('<strong>ERROR</strong>: You entered your new password only once.'), array('form-field' => 'pass1'));
} elseif (!empty($pass1) && empty($pass2)) {
$errors->add('pass', __('<strong>ERROR</strong>: You entered your new password only once.'), array('form-field' => 'pass2'));
}
//.........这里部分代码省略.........
示例8: _e
</td>
</tr>
<tr>
<th><label for="url"><?php
_e('Website');
?>
</label></th>
<td><input type="text" name="url" id="url" value="<?php
echo esc_attr($profileuser->user_url);
?>
" class="regular-text code" /></td>
</tr>
<?php
foreach (_wp_get_user_contactmethods($profileuser) as $name => $desc) {
?>
<tr>
<th><label for="<?php
echo $name;
?>
"><?php
echo apply_filters('user_' . $name . '_label', $desc);
?>
</label></th>
<td><input type="text" name="<?php
echo $name;
?>
" id="<?php
echo $name;
?>
示例9: wpmu_validate_user_signup
function wpmu_validate_user_signup($result)
{
$fields = $this->getFilters('gmember_extra_meta');
if (!count($fields)) {
// maybe filtered
return $result;
}
$this->_signup_meta = array();
$extra = gMemberHelper::buildMetaArray($fields, false, array(), 'member');
$this->_signup_meta['extra'] = gMemberHelper::sanitizeMetaArray($result['errors'], $extra, $fields, false);
foreach (_wp_get_user_contactmethods() as $method => $name) {
if (isset($_POST['contacts-' . $method])) {
$this->_signup_meta['contacts'][$method] = sanitize_text_field($_POST['contacts-' . $method]);
}
}
return $result;
}
示例10: bbp_edit_user_contact_methods
/**
* Return user contact methods Selectbox
*
* @since bbPress (r2688)
*
* @uses _wp_get_user_contactmethods() To get the contact methods
* @uses apply_filters() Calls 'bbp_edit_user_contact_methods' with the methods
* @return string User contact methods
*/
function bbp_edit_user_contact_methods()
{
// Get the core WordPress contact methods
$contact_methods = _wp_get_user_contactmethods(bbpress()->displayed_user);
return apply_filters('bbp_edit_user_contact_methods', $contact_methods);
}
示例11: import_user
/**
* Import a single user
*
* @param array $user
* @return array
*/
protected function import_user($user)
{
$local_user = get_user_by('login', $user['data']['user_login']);
$local_user_object = new WP_User($local_user->ID);
$update = !empty($local_user) ? true : false;
if (!function_exists('wp_insert_user')) {
include_once ABSPATH . 'wp-includes/registration.php';
}
// args used by wp_insert_user & wp_update_user
// makes for an easy merge and a reminder of just what is handled at that time
$insert_user_args = array('user_login' => null, 'user_nicename' => null, 'user_url' => null, 'user_email' => null, 'display_name' => null, 'nickname' => null, 'first_name' => null, 'last_name' => null, 'description' => null, 'rich_editing' => null, 'user_registered' => null, 'role' => null, 'use_ssl' => 0, 'admin_color' => null, 'comment_shortcuts' => null);
foreach (_wp_get_user_contactmethods() as $contact_method => $contact_method_name) {
$insert_user_args[$contact_method] = null;
}
cfd_tmp_dbg('importing_user.txt', $user, 'print');
foreach ($insert_user_args as $key => &$arg) {
if ($key == 'role') {
$arg = $user['roles'][0];
} else {
if (!empty($user['data'][$key])) {
$arg = $user['data'][$key];
}
}
}
cfd_tmp_dbg('importing_user_args.txt', $insert_user_args, 'print');
if ($update) {
$local_userdata = get_object_vars(get_userdata($local_user->ID));
$insert_user_args = array_merge($local_userdata, $insert_user_args);
unset($insert_user_args['user_pass']);
$user_id = wp_update_user($insert_user_args);
} else {
if (email_exists($user['data']['user_email'])) {
$this->add_import_message('users', '__error__', sprintf(__('Email address "%s" already exists for another user', 'cf-deploy'), $user['data']['user_email']));
return false;
}
// set generic password for new user
$insert_user_args['user_password'] = time();
$user_id = wp_insert_user($insert_user_args);
}
if (empty($user_id) || is_wp_error($user_id)) {
$errstring = sprintf(__('Import failed for user "%s".', 'cf-deploy'), $user['data']['user_nicename']);
if (is_wp_error($user_id)) {
$errstring .= ' ' . __('Error:', 'cf-deploy') . ' ' . $user_id->get_error_message();
}
$this->add_import_message('users', '__error__', $errstring);
$ret = false;
} else {
// Set/Update Capabilities & Roles
$u = new WP_User($user_id);
// set roles, remove all existing and replace with what is being brought in
foreach ($u->roles as $role) {
$u->remove_role($role);
}
foreach ($user['roles'] as $role) {
$u->add_role($role);
}
// set caps, remove all existing caps before setting them anew
$u->remove_all_caps();
foreach ($user['caps'] as $cap => $value) {
$u->add_cap($cap, (bool) $value);
}
$this->add_import_message('users', '__notice__', sprintf(__('User "%s" successfully imported.', 'cf-deploy'), $user['data']['user_login']));
$ret = true;
}
$item_change['users'][$user['data']['user_login']] = 'new';
if (!empty($local_user)) {
$log_users = array($local_user_object);
array_walk_recursive($log_users, array($this, 'object_to_array'));
$item_change['users'][$user['data']['user_login']] = current($log_users);
}
$this->log_item_change($item_change);
return $ret;
}
示例12: atcf_shortcode_profile_info_process
/**
* Process shortcode submission.
*
* @since Astoundify Crowdfunding 0.8
*
* @return void
*/
function atcf_shortcode_profile_info_process()
{
global $edd_options, $post;
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (empty($_POST['action']) || 'atcf-profile-update' !== $_POST['action']) {
return;
}
if (!wp_verify_nonce($_POST['_wpnonce'], 'atcf-profile-update')) {
return;
}
$user = wp_get_current_user();
$errors = new WP_Error();
$bio = esc_attr($_POST['bio']);
$nicename = esc_attr($_POST['nicename']);
$url = esc_url($_POST['url']);
do_action('atcf_shortcode_profile_info_process_validate', $_POST, $errors);
if (!empty($errors->errors)) {
// Not sure how to avoid empty instantiated WP_Error
wp_die($errors);
}
wp_update_user(apply_filters('atcf_shortcode_profile_info_process_update', array('ID' => $user->ID, 'description' => $bio, 'display_name' => $nicename, 'user_nicename' => $user->user_nicename, 'user_url' => $url)));
foreach (_wp_get_user_contactmethods() as $method => $name) {
if (isset($_POST[$method])) {
update_user_meta($user->ID, $method, sanitize_text_field($_POST[$method]));
}
}
do_action('atcf_shortcode_profile_info_process_after', $user, $_POST);
$redirect = apply_filters('atcf_shortcode_profile_info_success_redirect', add_query_arg(array('success' => 'true'), get_permalink()));
wp_safe_redirect($redirect);
exit;
}
示例13: wpuf_user_edit_profile_form
/**
* Shows the user profile form
*
* @global type $userdata
* @param type $user_id
*/
function wpuf_user_edit_profile_form($user_id = null)
{
global $userdata, $wp_http_referer;
get_currentuserinfo();
if (!function_exists('get_user_to_edit')) {
require_once ABSPATH . '/wp-admin/includes/user.php';
}
if (!function_exists('_wp_get_user_contactmethods')) {
require_once ABSPATH . '/wp-includes/registration.php';
}
if (!$user_id) {
$current_user = wp_get_current_user();
$user_id = $user_ID = $current_user->ID;
}
if (isset($_POST['submit'])) {
check_admin_referer('update-profile_' . $user_id);
$errors = edit_user($user_id);
if (is_wp_error($errors)) {
$message = $errors->get_error_message();
$style = 'error';
} else {
$message = __('<strong>Success</strong>: Profile updated', 'wpuf');
$style = 'success';
do_action('personal_options_update', $user_id);
}
}
$profileuser = get_user_to_edit($user_id);
if (isset($message)) {
echo '<div class="' . $style . '">' . $message . '</div>';
}
?>
<div class="wpuf-profile">
<form name="profile" id="your-profile" action="" method="post">
<?php
wp_nonce_field('update-profile_' . $user_id);
?>
<?php
if ($wp_http_referer) {
?>
<input type="hidden" name="wp_http_referer" value="<?php
echo esc_url($wp_http_referer);
?>
" />
<?php
}
?>
<input type="hidden" name="from" value="profile" />
<input type="hidden" name="checkuser_id" value="<?php
echo $user_id;
?>
" />
<table class="wpuf-table">
<?php
do_action('personal_options', $profileuser);
?>
</table>
<?php
do_action('profile_personal_options', $profileuser);
?>
<fieldset>
<legend><?php
_e('Name');
?>
</legend>
<table class="wpuf-table">
<tr>
<th><label for="user_login1"><?php
_e('Username');
?>
</label></th>
<td><input type="text" name="user_login" id="user_login1" value="<?php
echo esc_attr($profileuser->user_login);
?>
" disabled="disabled" class="regular-text" /><br /><em><span class="description"><?php
_e('Usernames cannot be changed.');
?>
</span></em></td>
</tr>
<tr>
<th><label for="first_name"><?php
_e('First Name');
?>
</label></th>
<td><input type="text" name="first_name" id="first_name" value="<?php
echo esc_attr($profileuser->first_name);
?>
" class="regular-text" /></td>
</tr>
<tr>
<th><label for="last_name"><?php
_e('Last Name');
//.........这里部分代码省略.........
示例14: Simplr_usr_profiler
//.........这里部分代码省略.........
if (is_array($rem) && in_array('last_name', $rem)) {
echo ' checked="checked" ';
}
?>
/> Last Name</td></tr>
<tr><td> <input type="checkbox" name ="to_hide[]" value="nickname" <?php
if (is_array($toHide) && in_array('nickname', $toHide)) {
echo ' checked="checked" ';
}
?>
/> Nickname</td></tr>
<tr><td> <input type="checkbox" name ="to_hide[]" value="display_name" <?php
if (is_array($toHide) && in_array('display_name', $toHide)) {
echo ' checked="checked" ';
}
?>
/> Display Name</td></tr>
<tr><td> </td></tr>
<tr> <td> Change Contact Info Label to: <input name="contact" value="<?php
echo get_option('usrprof_contact');
?>
" /></td></tr>
<tr><td> <input type="checkbox" name ="to_remove[]" value="url" <?php
if (is_array($rem) && in_array('url', $rem)) {
echo ' checked="checked" ';
}
?>
/> Website</td></tr>
<?php
foreach (_wp_get_user_contactmethods() as $name => $desc) {
?>
<tr><td> <input type="checkbox" name ="to_remove[]" value="<?php
echo $name;
?>
" <?php
if (is_array($rem) && in_array($name, $rem)) {
echo ' checked="checked" ';
}
?>
/><?php
echo apply_filters('user_' . $name . '_label', $desc);
?>
</td></tr>
<?php
}
?>
<tr><td> </td></tr>
<tr> <td> Change About Yourself Label to: <input name="about" value="<?php
echo get_option('usrprof_about');
?>
" /></td></tr>
<tr><td> <input type="checkbox" name ="to_remove[]" value="description" <?php
if (is_array($rem) && in_array('description', $rem)) {
echo ' checked="checked" ';
}
?>
/> Biographical Info </td></tr>
示例15: wp_insert_user
//.........这里部分代码省略.........
}
$user_login = sanitize_user($user_login, true);
$user_login = apply_filters('pre_user_login', $user_login);
if (empty($user_nicename)) {
$user_nicename = sanitize_title($user_login);
}
$user_nicename = apply_filters('pre_user_nicename', $user_nicename);
if (empty($user_url)) {
$user_url = '';
}
$user_url = apply_filters('pre_user_url', $user_url);
if (empty($user_email)) {
$user_email = '';
}
$user_email = apply_filters('pre_user_email', $user_email);
if (empty($display_name)) {
$display_name = $user_login;
}
$display_name = apply_filters('pre_user_display_name', $display_name);
if (empty($nickname)) {
$nickname = $user_login;
}
$nickname = apply_filters('pre_user_nickname', $nickname);
if (empty($first_name)) {
$first_name = '';
}
$first_name = apply_filters('pre_user_first_name', $first_name);
if (empty($last_name)) {
$last_name = '';
}
$last_name = apply_filters('pre_user_last_name', $last_name);
if (empty($description)) {
$description = '';
}
$description = apply_filters('pre_user_description', $description);
if (empty($rich_editing)) {
$rich_editing = 'true';
}
if (empty($comment_shortcuts)) {
$comment_shortcuts = 'false';
}
if (empty($admin_color)) {
$admin_color = 'fresh';
}
$admin_color = preg_replace('|[^a-z0-9 _.\\-@]|i', '', $admin_color);
if (empty($use_ssl)) {
$use_ssl = 0;
}
if (empty($user_registered)) {
$user_registered = gmdate('Y-m-d H:i:s');
}
$user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_nicename = %s AND user_login != %s LIMIT 1", $user_nicename, $user_login));
if ($user_nicename_check) {
$suffix = 2;
while ($user_nicename_check) {
$alt_user_nicename = $user_nicename . "-{$suffix}";
$user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login));
$suffix++;
}
$user_nicename = $alt_user_nicename;
}
$data = compact('user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered');
$data = stripslashes_deep($data);
if ($update) {
$wpdb->update($wpdb->users, $data, compact('ID'));
$user_id = (int) $ID;
} else {
$wpdb->insert($wpdb->users, $data + compact('user_login'));
$user_id = (int) $wpdb->insert_id;
}
update_usermeta($user_id, 'first_name', $first_name);
update_usermeta($user_id, 'last_name', $last_name);
update_usermeta($user_id, 'nickname', $nickname);
update_usermeta($user_id, 'description', $description);
update_usermeta($user_id, 'rich_editing', $rich_editing);
update_usermeta($user_id, 'comment_shortcuts', $comment_shortcuts);
update_usermeta($user_id, 'admin_color', $admin_color);
update_usermeta($user_id, 'use_ssl', $use_ssl);
foreach (_wp_get_user_contactmethods() as $method => $name) {
if (empty(${$method})) {
${$method} = '';
}
update_usermeta($user_id, $method, ${$method});
}
if (isset($role)) {
$user = new WP_User($user_id);
$user->set_role($role);
} elseif (!$update) {
$user = new WP_User($user_id);
$user->set_role(get_option('default_role'));
}
wp_cache_delete($user_id, 'users');
wp_cache_delete($user_login, 'userlogins');
if ($update) {
do_action('profile_update', $user_id, $old_user_data);
} else {
do_action('user_register', $user_id);
}
return $user_id;
}