Pass user object through _wp_get_user_contactmethods() to the user_contactmethods filter. props aaroncampbell, fixes #15186.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15896 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-10-21 15:42:06 +00:00
parent 99a5439b44
commit f5e23028ff
3 changed files with 11 additions and 11 deletions

View File

@ -110,7 +110,7 @@ function edit_user( $user_id = 0 ) {
if ( isset( $_POST['description'] ) )
$user->description = trim( $_POST['description'] );
foreach ( _wp_get_user_contactmethods() as $method => $name ) {
foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
if ( isset( $_POST[$method] ))
$user->$method = sanitize_text_field( $_POST[$method] );
}
@ -224,7 +224,7 @@ function get_editable_roles() {
function get_user_to_edit( $user_id ) {
$user = new WP_User( $user_id );
$user_contactmethods = _wp_get_user_contactmethods();
$user_contactmethods = _wp_get_user_contactmethods( $user );
foreach ($user_contactmethods as $method => $name) {
if ( empty( $user->{$method} ) )
$user->{$method} = '';

View File

@ -322,7 +322,7 @@ else
</tr>
<?php
foreach (_wp_get_user_contactmethods() as $name => $desc) {
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>

View File

@ -211,20 +211,19 @@ function wp_insert_user($userdata) {
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 ) {
$user = new WP_User($user_id);
foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
if ( empty($$method) )
$$method = '';
update_user_meta( $user_id, $method, $$method );
}
if ( isset($role) ) {
$user = new WP_User($user_id);
if ( isset($role) )
$user->set_role($role);
} elseif ( !$update ) {
$user = new WP_User($user_id);
elseif ( !$update )
$user->set_role(get_option('default_role'));
}
wp_cache_delete($user_id, 'users');
wp_cache_delete($user_login, 'userlogins');
@ -319,15 +318,16 @@ function wp_create_user($username, $password, $email = '') {
* @access private
* @since
*
* @param object $user User data object (optional)
* @return array $user_contactmethods Array of contact methods and their labels.
*/
function _wp_get_user_contactmethods() {
function _wp_get_user_contactmethods( $user = null ) {
$user_contactmethods = array(
'aim' => __('AIM'),
'yim' => __('Yahoo IM'),
'jabber' => __('Jabber / Google Talk')
);
return apply_filters('user_contactmethods',$user_contactmethods);
return apply_filters( 'user_contactmethods', $user_contactmethods, $user );
}
?>