From 0ab61b644151ca3458e875acecf3dc1fe8174715 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 11 Jul 2023 08:58:50 +0200 Subject: [PATCH] make `is_user_disabled` filterable --- includes/functions.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 05e14b9..15a769e 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -281,29 +281,39 @@ function is_activitypub_request() { * @return boolean True if the user is disabled, false otherwise. */ function is_user_disabled( $user_id ) { + $return = false; + switch ( $user_id ) { // if the user is the application user, it's always enabled. case \Activitypub\Collection\Users::APPLICATION_USER_ID: - return false; + $return = false; + break; // if the user is the blog user, it's only enabled in single-user mode. case \Activitypub\Collection\Users::BLOG_USER_ID: if ( defined( 'ACTIVITYPUB_DISABLE_BLOG_USER' ) ) { - return ACTIVITYPUB_DISABLE_BLOG_USER; + $return = ACTIVITYPUB_DISABLE_BLOG_USER; + break; } - return false; + $return = false; + break; // if the user is any other user, it's enabled if it can publish posts. default: if ( defined( 'ACTIVITYPUB_DISABLE_USER' ) ) { - return ACTIVITYPUB_DISABLE_USER; + $return = ACTIVITYPUB_DISABLE_USER; + break; } if ( ! \user_can( $user_id, 'publish_posts' ) ) { - return true; + $return = true; + break; } - return false; + $return = false; + break; } + + return apply_filters( 'activitypub_is_user_disabled', $return, $user_id ); } /**