summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-module-users.php')
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-users.php44
1 files changed, 39 insertions, 5 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-users.php b/plugins/jetpack/sync/class.jetpack-sync-module-users.php
index 46fd7118..420a73cd 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-users.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-users.php
@@ -50,7 +50,6 @@ class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
// user authentication
add_action( 'wp_login', $callable, 10, 2 );
- add_action( 'wp_login_failed', $callable, 10, 2 );
add_action( 'wp_logout', $callable, 10, 0 );
add_action( 'wp_masterbar_logout', $callable, 10, 0 );
}
@@ -71,9 +70,8 @@ class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
}
public function sanitize_user_and_expand( $user ) {
- $user = $this->sanitize_user( $user );
-
- return $this->add_to_user( $user );
+ $user = $this->add_to_user( $user );
+ return $this->sanitize_user( $user );
}
public function sanitize_user( $user ) {
@@ -84,6 +82,7 @@ class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
unset( $user->data->user_pass );
}
+ $user->allcaps = $this->get_real_user_capabilities( $user );
return $user;
}
@@ -101,6 +100,16 @@ class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
return $user;
}
+ public function get_real_user_capabilities( $user ) {
+ $user_capabilities = array();
+ foreach( Jetpack_Sync_Defaults::get_capabilities_whitelist() as $capability ) {
+ if ( $user_has_capabilities = user_can( $user , $capability ) ) {
+ $user_capabilities[ $capability ] = true;
+ }
+ }
+ return $user_capabilities;
+ }
+
public function expand_user( $args ) {
list( $user ) = $args;
@@ -130,10 +139,27 @@ class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
}
public function deleted_user_handler( $deleted_user_id, $reassigned_user_id = '' ) {
- do_action( 'jetpack_deleted_user', $deleted_user_id, $reassigned_user_id, is_multisite() );
+ $is_multisite = is_multisite();
+ /**
+ * Fires when a user is deleted on a site
+ *
+ * @since 5.4.0
+ *
+ * @param int $deleted_user_id - ID of the deleted user
+ * @param int $reassigned_user_id - ID of the user the deleted user's posts is reassigned to (if any)
+ * @param bool $is_multisite - Whether this site is a multisite installation
+ */
+ do_action( 'jetpack_deleted_user', $deleted_user_id, $reassigned_user_id, $is_multisite );
}
public function edited_user_handler( $user_id ) {
+ /**
+ * Fires when a user is edited on a site
+ *
+ * @since 5.4.0
+ *
+ * @param int $user_id - ID of the edited user
+ */
do_action( 'jetpack_user_edited', $user_id );
}
@@ -331,6 +357,14 @@ class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
$reassigned_user_id = $this->get_reassigned_network_user_id();
//Note that we are in the context of the blog the user is removed from, see https://github.com/WordPress/WordPress/blob/473e1ba73bc5c18c72d7f288447503713d518790/wp-includes/ms-functions.php#L233
+ /**
+ * Fires when a user is removed from a blog on a multisite installation
+ *
+ * @since 5.4.0
+ *
+ * @param int $user_id - ID of the removed user
+ * @param int $reassigned_user_id - ID of the user the removed user's posts is reassigned to (if any)
+ */
do_action( 'jetpack_removed_user_from_blog', $user_id, $reassigned_user_id );
}