Don't use deprecated *_usermeta() functions. Props technosailor fixes #10837

git-svn-id: http://svn.automattic.com/wordpress/trunk@13311 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-02-22 21:25:32 +00:00
parent 2b182d39d9
commit 2ce7dc4dac
14 changed files with 72 additions and 72 deletions

View File

@ -998,11 +998,11 @@ case 'closed-postboxes' :
die('-1');
if ( is_array($closed) )
update_usermeta($user->ID, 'closedpostboxes_'.$page, $closed);
update_user_meta($user->ID, 'closedpostboxes_'.$page, $closed);
if ( is_array($hidden) ) {
$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv') ); // postboxes that are always shown
update_usermeta($user->ID, 'meta-box-hidden_'.$page, $hidden);
update_user_meta($user->ID, 'meta-box-hidden_'.$page, $hidden);
}
die('1');
@ -1020,7 +1020,7 @@ case 'hidden-columns' :
die('-1');
if ( is_array($hidden) )
update_usermeta($user->ID, "manage-$page-columns-hidden", $hidden);
update_user_meta($user->ID, "manage-$page-columns-hidden", $hidden);
die('1');
break;
@ -1040,7 +1040,7 @@ case 'meta-box-order':
update_user_option($user->ID, "meta-box-order_$page", $order);
if ( $page_columns )
update_usermeta($user->ID, "screen_layout_$page", $page_columns);
update_user_meta($user->ID, "screen_layout_$page", $page_columns);
die('1');
break;

View File

@ -257,10 +257,10 @@ class Dotclear_Import {
else if (2 <= $wp_perms) { $user->set_role('contributor'); }
else { $user->set_role('subscriber'); }
update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
update_usermeta( $ret_id, 'rich_editing', 'false');
update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
update_usermeta( $ret_id, 'last_name', csc ($user_nom));
update_user_meta( $ret_id, 'wp_user_level', $wp_perms);
update_user_meta( $ret_id, 'rich_editing', 'false');
update_user_meta( $ret_id, 'first_name', csc ($user_prenom));
update_user_meta( $ret_id, 'last_name', csc ($user_nom));
}// End foreach($users as $user)
// Store id translation array for future use

View File

@ -265,8 +265,8 @@ class Textpattern_Import {
if('2' == $transperms[$privs]) { $user->set_role('contributor'); }
if('0' == $transperms[$privs]) { $user->set_role('subscriber'); }
update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
update_usermeta( $ret_id, 'rich_editing', 'false');
update_user_meta( $ret_id, 'wp_user_level', $transperms[$privs] );
update_user_meta( $ret_id, 'rich_editing', 'false');
}// End foreach($users as $user)
// Store id translation array for future use

View File

@ -424,7 +424,7 @@ function set_screen_options() {
break;
}
update_usermeta($user->ID, $option, $value);
update_user_meta($user->ID, $option, $value);
wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
exit;
}

View File

@ -543,12 +543,12 @@ function redirect_user_to_blog() {
if ( !empty( $blogs ) ) {
foreach( $blogs as $blogid => $blog ) {
if ( $blogid != $dashboard_blog->blog_id && get_usermeta( $current_user->ID , 'primary_blog' ) == $dashboard_blog->blog_id ) {
update_usermeta( $current_user->ID, 'primary_blog', $blogid );
if ( $blogid != $dashboard_blog->blog_id && get_user_meta( $current_user->ID , 'primary_blog' ) == $dashboard_blog->blog_id ) {
update_user_meta( $current_user->ID, 'primary_blog', $blogid );
continue;
}
}
$blog = get_blog_details( get_usermeta( $current_user->ID , 'primary_blog' ) );
$blog = get_blog_details( get_user_meta( $current_user->ID , 'primary_blog' ) );
$protocol = ( is_ssl() ? 'https://' : 'http://' );
wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case"
exit;
@ -690,7 +690,7 @@ function choose_primary_blog() {
<td>
<?php
$all_blogs = get_blogs_of_user( $current_user->ID );
$primary_blog = get_usermeta($current_user->ID, 'primary_blog');
$primary_blog = get_user_meta($current_user->ID, 'primary_blog');
if ( count( $all_blogs ) > 1 ) {
$found = false;
?>
@ -704,13 +704,13 @@ function choose_primary_blog() {
<?php
if ( !$found ) {
$blog = array_shift( $all_blogs );
update_usermeta( $current_user->ID, 'primary_blog', $blog->userblog_id );
update_user_meta( $current_user->ID, 'primary_blog', $blog->userblog_id );
}
} elseif ( count( $all_blogs ) == 1 ) {
$blog = array_shift( $all_blogs );
echo $blog->domain;
if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
update_usermeta( $current_user->ID, 'primary_blog', $blog->userblog_id );
update_user_meta( $current_user->ID, 'primary_blog', $blog->userblog_id );
} else {
echo "N/A";
}

View File

@ -721,8 +721,8 @@ Thanks!
if ( !is_multisite() ) {
$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path ) );
$blog_id = $wpdb->insert_id;
update_usermeta( $site_user->ID, 'source_domain', $domain );
update_usermeta( $site_user->ID, 'primary_blog', $blog_id );
update_user_meta( $site_user->ID, 'source_domain', $domain );
update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
}
if ( $vhost == 'yes' )

View File

@ -671,23 +671,23 @@ function upgrade_160() {
$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
foreach ( $users as $user ) :
if ( !empty( $user->user_firstname ) )
update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
update_user_meta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
if ( !empty( $user->user_lastname ) )
update_usermeta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
update_user_meta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
if ( !empty( $user->user_nickname ) )
update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
update_user_meta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
if ( !empty( $user->user_level ) )
update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
if ( !empty( $user->user_icq ) )
update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
update_user_meta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
if ( !empty( $user->user_aim ) )
update_usermeta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
update_user_meta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
if ( !empty( $user->user_msn ) )
update_usermeta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
update_user_meta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
if ( !empty( $user->user_yim ) )
update_usermeta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
update_user_meta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
if ( !empty( $user->user_description ) )
update_usermeta( $user->ID, 'description', $wpdb->escape($user->user_description) );
update_user_meta( $user->ID, 'description', $wpdb->escape($user->user_description) );
if ( isset( $user->user_idmode ) ):
$idmode = $user->user_idmode;
@ -702,11 +702,11 @@ function upgrade_160() {
endif;
// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
$caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
if ( empty($caps) || defined('RESET_CAPS') ) {
$level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level');
$role = translate_level_to_role($level);
update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
}
endforeach;

View File

@ -96,7 +96,7 @@ switch ( $_GET['action'] ) {
foreach ( (array)$move_users as $user_id ) {
remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) );
add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
update_usermeta( $user_id, 'primary_blog', $dashboard_blog_id );
update_user_meta( $user_id, 'primary_blog', $dashboard_blog_id );
}
}
}

View File

@ -30,7 +30,7 @@ $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $defa
if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) )
$status = 'all';
if ( $status != $default_status && 'search' != $status )
update_usermeta($current_user->ID, 'plugins_last_view', $status);
update_user_meta($current_user->ID, 'plugins_last_view', $status);
$page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;

View File

@ -123,7 +123,7 @@ if ( !is_multisite() ) {
if ( !isset( $errors ) || ( isset( $errors ) && is_object( $errors ) && false == $errors->get_error_codes() ) )
$errors = edit_user($user_id);
if ( $delete_role ) // stops users being added to current blog when they are edited
update_usermeta( $user_id, $blog_prefix . 'capabilities' , '' );
update_user_meta( $user_id, $blog_prefix . 'capabilities' , '' );
}
if ( !is_wp_error( $errors ) ) {

View File

@ -567,7 +567,7 @@ class WP_User {
*/
function add_role( $role ) {
$this->caps[$role] = true;
update_usermeta( $this->ID, $this->cap_key, $this->caps );
update_user_meta( $this->ID, $this->cap_key, $this->caps );
$this->get_role_caps();
$this->update_user_level_from_caps();
}
@ -584,7 +584,7 @@ class WP_User {
if ( empty( $this->roles[$role] ) || ( count( $this->roles ) <= 1 ) )
return;
unset( $this->caps[$role] );
update_usermeta( $this->ID, $this->cap_key, $this->caps );
update_user_meta( $this->ID, $this->cap_key, $this->caps );
$this->get_role_caps();
}
@ -609,7 +609,7 @@ class WP_User {
} else {
$this->roles = false;
}
update_usermeta( $this->ID, $this->cap_key, $this->caps );
update_user_meta( $this->ID, $this->cap_key, $this->caps );
$this->get_role_caps();
$this->update_user_level_from_caps();
do_action( 'set_user_role', $this->ID, $role );
@ -656,7 +656,7 @@ class WP_User {
function update_user_level_from_caps() {
global $wpdb;
$this->user_level = array_reduce( array_keys( $this->allcaps ), array( &$this, 'level_reduction' ), 0 );
update_usermeta( $this->ID, $wpdb->prefix . 'user_level', $this->user_level );
update_user_meta( $this->ID, $wpdb->prefix . 'user_level', $this->user_level );
}
/**
@ -670,7 +670,7 @@ class WP_User {
*/
function add_cap( $cap, $grant = true ) {
$this->caps[$cap] = $grant;
update_usermeta( $this->ID, $this->cap_key, $this->caps );
update_user_meta( $this->ID, $this->cap_key, $this->caps );
}
/**
@ -685,7 +685,7 @@ class WP_User {
if ( empty( $this->caps[$cap] ) )
return;
unset( $this->caps[$cap] );
update_usermeta( $this->ID, $this->cap_key, $this->caps );
update_user_meta( $this->ID, $this->cap_key, $this->caps );
}
/**
@ -697,8 +697,8 @@ class WP_User {
function remove_all_caps() {
global $wpdb;
$this->caps = array();
update_usermeta( $this->ID, $this->cap_key, '' );
update_usermeta( $this->ID, $wpdb->prefix . 'user_level', '' );
update_user_meta( $this->ID, $this->cap_key, '' );
update_user_meta( $this->ID, $wpdb->prefix . 'user_level', '' );
$this->get_role_caps();
}

View File

@ -77,25 +77,25 @@ function get_active_blog_for_user( $user_id ) { // get an active blog for user -
if ( empty( $blogs ) ) {
$details = get_dashboard_blog();
add_user_to_blog( $details->blog_id, $user_id, 'subscriber' );
update_usermeta( $user_id, 'primary_blog', $details->blog_id );
update_user_meta( $user_id, 'primary_blog', $details->blog_id );
wp_cache_delete( $user_id, 'users' );
return $details;
}
$primary_blog = get_usermeta( $user_id, "primary_blog" );
$primary_blog = get_user_meta( $user_id, "primary_blog" );
$details = get_dashboard_blog();
if ( $primary_blog ) {
$blogs = get_blogs_of_user( $user_id );
if ( isset( $blogs[ $primary_blog ] ) == false ) {
add_user_to_blog( $details->blog_id, $user_id, 'subscriber' );
update_usermeta( $user_id, 'primary_blog', $details->blog_id );
update_user_meta( $user_id, 'primary_blog', $details->blog_id );
wp_cache_delete( $user_id, 'users' );
} else {
$details = get_blog_details( $primary_blog );
}
} else {
add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog
update_usermeta( $user_id, 'primary_blog', $details->blog_id );
update_user_meta( $user_id, 'primary_blog', $details->blog_id );
}
if ( ( is_object( $details ) == false ) || ( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) ) {
@ -109,12 +109,12 @@ function get_active_blog_for_user( $user_id ) { // get an active blog for user -
if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
$ret = $blog;
$changed = false;
if ( get_usermeta( $user_id , 'primary_blog' ) != $blog_id ) {
update_usermeta( $user_id, 'primary_blog', $blog_id );
if ( get_user_meta( $user_id , 'primary_blog' ) != $blog_id ) {
update_user_meta( $user_id, 'primary_blog', $blog_id );
$changed = true;
}
if ( !get_usermeta($user_id , 'source_domain') ) {
update_usermeta( $user_id, 'source_domain', $blog->domain );
if ( !get_user_meta($user_id , 'source_domain') ) {
update_user_meta( $user_id, 'source_domain', $blog->domain );
$changed = true;
}
if ( $changed )
@ -126,7 +126,7 @@ function get_active_blog_for_user( $user_id ) { // get an active blog for user -
// Should never get here
$dashboard_blog = get_dashboard_blog();
add_user_to_blog( $dashboard_blog->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog
update_usermeta( $user_id, 'primary_blog', $dashboard_blog->blog_id );
update_user_meta( $user_id, 'primary_blog', $dashboard_blog->blog_id );
return $dashboard_blog;
}
return $ret;
@ -248,10 +248,10 @@ function add_user_to_blog( $blog_id, $user_id, $role ) {
if ( empty($user) )
return new WP_Error('user_does_not_exist', __('That user does not exist.'));
if ( !get_usermeta($user_id, 'primary_blog') ) {
update_usermeta($user_id, 'primary_blog', $blog_id);
if ( !get_user_meta($user_id, 'primary_blog') ) {
update_user_meta($user_id, 'primary_blog', $blog_id);
$details = get_blog_details($blog_id);
update_usermeta($user_id, 'source_domain', $details->domain);
update_user_meta($user_id, 'source_domain', $details->domain);
}
$user->set_role($role);
@ -270,7 +270,7 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
// If being removed from the primary blog, set a new primary if the user is assigned
// to multiple blogs.
$primary_blog = get_usermeta($user_id, 'primary_blog');
$primary_blog = get_user_meta($user_id, 'primary_blog');
if ( $primary_blog == $blog_id ) {
$new_id = '';
$new_domain = '';
@ -283,8 +283,8 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
break;
}
update_usermeta($user_id, 'primary_blog', $new_id);
update_usermeta($user_id, 'source_domain', $new_domain);
update_user_meta($user_id, 'primary_blog', $new_id);
update_user_meta($user_id, 'source_domain', $new_domain);
}
// wp_revoke_user($user_id);
@ -293,8 +293,8 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
$blogs = get_blogs_of_user($user_id);
if ( count($blogs) == 0 ) {
update_usermeta($user_id, 'primary_blog', '');
update_usermeta($user_id, 'source_domain', '');
update_user_meta($user_id, 'primary_blog', '');
update_user_meta($user_id, 'source_domain', '');
}
if ( $reassign != '' ) {
@ -826,8 +826,8 @@ function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id
add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
update_option( 'blog_public', $meta['public'] );
if ( !is_super_admin() && get_usermeta( $user_id, 'primary_blog' ) == get_site_option( 'dashboard_blog', 1 ) )
update_usermeta( $user_id, 'primary_blog', $blog_id );
if ( !is_super_admin() && get_user_meta( $user_id, 'primary_blog' ) == get_site_option( 'dashboard_blog', 1 ) )
update_user_meta( $user_id, 'primary_blog', $blog_id );
restore_current_blog();
do_action( 'wpmu_new_blog', $blog_id, $user_id );
@ -1306,7 +1306,7 @@ function add_new_user_to_blog( $user_id, $email, $meta ) {
$role = $meta[ 'new_role' ];
remove_user_from_blog($user_id, $current_site->blogid); // remove user from main blog.
add_user_to_blog( $blog_id, $user_id, $role );
update_usermeta( $user_id, 'primary_blog', $blog_id );
update_user_meta( $user_id, 'primary_blog', $blog_id );
}
}

View File

@ -202,20 +202,20 @@ function wp_insert_user($userdata) {
$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);
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_usermeta( $user_id, $method, $$method );
update_user_meta( $user_id, $method, $$method );
}
if ( isset($role) ) {

View File

@ -267,7 +267,7 @@ function update_user_option( $user_id, $option_name, $newvalue, $global = false
global $wpdb;
if ( !$global )
$option_name = $wpdb->prefix . $option_name;
return update_usermeta( $user_id, $option_name, $newvalue );
return update_user_meta( $user_id, $option_name, $newvalue );
}
/**