mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-26 08:55:13 +00:00
In WP_User
, ->get_role_caps()
and ->update_user_level_from_caps()
must be called inside ->add_cap()
and ->remove_cap()
after updating user meta. ->has_cap()
checks are currently failing directly after calling ->add_cap()
.
Adds unit test. Props rachelbaker. Fixes #28374. Built from https://develop.svn.wordpress.org/trunk@31190 git-svn-id: http://core.svn.wordpress.org/trunk@31171 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cf6adef68f
commit
6f8e01adf2
@ -934,6 +934,8 @@ class WP_User {
|
||||
public function add_cap( $cap, $grant = true ) {
|
||||
$this->caps[$cap] = $grant;
|
||||
update_user_meta( $this->ID, $this->cap_key, $this->caps );
|
||||
$this->get_role_caps();
|
||||
$this->update_user_level_from_caps();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -945,10 +947,13 @@ class WP_User {
|
||||
* @param string $cap Capability name.
|
||||
*/
|
||||
public function remove_cap( $cap ) {
|
||||
if ( ! isset( $this->caps[$cap] ) )
|
||||
if ( ! isset( $this->caps[ $cap ] ) ) {
|
||||
return;
|
||||
unset( $this->caps[$cap] );
|
||||
}
|
||||
unset( $this->caps[ $cap ] );
|
||||
update_user_meta( $this->ID, $this->cap_key, $this->caps );
|
||||
$this->get_role_caps();
|
||||
$this->update_user_level_from_caps();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31189';
|
||||
$wp_version = '4.2-alpha-31190';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user