From 3141ef88cfa7a50e74adf63da85720e33ec1f72f Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 4 Mar 2021 16:34:33 -0500 Subject: [PATCH] WordPress: avoid PHP notice if the anonymous user does not have any capabilities --- CRM/Core/Permission/WordPress.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CRM/Core/Permission/WordPress.php b/CRM/Core/Permission/WordPress.php index 3325d0fc117c..03eeb9be3b0f 100644 --- a/CRM/Core/Permission/WordPress.php +++ b/CRM/Core/Permission/WordPress.php @@ -76,10 +76,8 @@ public function check($str, $userId = NULL) { else { //check the capabilities of Anonymous user) $roleObj = new WP_Roles(); - if ( - $roleObj->get_role('anonymous_user') != NULL && - array_key_exists($str, $roleObj->get_role('anonymous_user')->capabilities) - ) { + $anonObj = $roleObj->get_role('anonymous_user'); + if (!empty($anonObj->capabilities) && array_key_exists($str, $anonObj->capabilities)) { return TRUE; } }