Don't treat a numeric user name as an id.
git-svn-id: https://develop.svn.wordpress.org/trunk@3310 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ecea3fad26
commit
44fc04c42e
@ -114,18 +114,22 @@ class WP_User {
|
||||
var $roles = array();
|
||||
var $allcaps = array();
|
||||
|
||||
function WP_User($id) {
|
||||
function WP_User($id, $name = '') {
|
||||
global $wp_roles, $table_prefix;
|
||||
|
||||
if ( empty($id) )
|
||||
if ( empty($id) && empty($name) )
|
||||
return;
|
||||
|
||||
if ( is_numeric($id) ) {
|
||||
$this->data = get_userdata($id);
|
||||
} else {
|
||||
$this->data = get_userdatabylogin($id);
|
||||
if ( ! is_numeric($id) ) {
|
||||
$name = $id;
|
||||
$id = 0;
|
||||
}
|
||||
|
||||
if ( ! empty($id) )
|
||||
$this->data = get_userdata($id);
|
||||
else
|
||||
$this->data = get_userdatabylogin($name);
|
||||
|
||||
if ( empty($this->data->ID) )
|
||||
return;
|
||||
|
||||
|
@ -187,7 +187,7 @@ default:
|
||||
do_action('wp_authenticate', array(&$user_login, &$user_pass));
|
||||
|
||||
if ( $_POST ) {
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
|
||||
// If the user can't edit posts, send them to their profile.
|
||||
if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
|
||||
|
22
xmlrpc.php
22
xmlrpc.php
@ -179,7 +179,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
$is_admin = $user->has_cap('level_8');
|
||||
|
||||
$struct = array(
|
||||
@ -317,7 +317,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_themes') ) {
|
||||
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
|
||||
}
|
||||
@ -352,7 +352,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_themes') ) {
|
||||
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
|
||||
}
|
||||
@ -391,7 +391,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap($cap) )
|
||||
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
|
||||
|
||||
@ -445,7 +445,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$this->escape($actual_post);
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
|
||||
|
||||
@ -489,7 +489,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return new IXR_Error(404, 'Sorry, no such post.');
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
|
||||
|
||||
@ -525,7 +525,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('publish_posts') )
|
||||
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
|
||||
|
||||
@ -605,7 +605,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
||||
|
||||
@ -844,7 +844,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if ( !$this->login_pass_ok($user_login, $user_pass) )
|
||||
return $this->error;
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
|
||||
if ( !$user->has_cap('upload_files') ) {
|
||||
logIO('O', '(MW) User does not have upload_files capability');
|
||||
@ -984,7 +984,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
||||
|
||||
@ -1066,7 +1066,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = new WP_User($user_login);
|
||||
$user = new WP_User(0, $user_login);
|
||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user