From: Mathieu Lutfy Date: Thu, 4 Mar 2021 21:34:33 +0000 (-0500) Subject: WordPress: avoid PHP notice if the anonymous user does not have any capabilities X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3141ef88cfa7a50e74adf63da85720e33ec1f72f;p=civicrm-core.git WordPress: avoid PHP notice if the anonymous user does not have any capabilities --- diff --git a/CRM/Core/Permission/WordPress.php b/CRM/Core/Permission/WordPress.php index 3325d0fc11..03eeb9be3b 100644 --- a/CRM/Core/Permission/WordPress.php +++ b/CRM/Core/Permission/WordPress.php @@ -76,10 +76,8 @@ class CRM_Core_Permission_WordPress extends CRM_Core_Permission_Base { 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; } }