From ca64f9815927c476c4100a8e04f8b5a953355b20 Mon Sep 17 00:00:00 2001 From: Miguel Peixe Date: Fri, 13 Sep 2024 16:26:25 -0300 Subject: [PATCH] fix: check for non-preview logged in user on account criteria --- includes/class-newspack-popups-criteria.php | 3 ++- src/criteria/default/user-account.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/class-newspack-popups-criteria.php b/includes/class-newspack-popups-criteria.php index ae6023d74..900656046 100644 --- a/includes/class-newspack-popups-criteria.php +++ b/includes/class-newspack-popups-criteria.php @@ -62,7 +62,8 @@ public static function enqueue_scripts() { self::SCRIPT_HANDLE, 'newspackPopupsCriteria', [ - 'config' => self::get_criteria_config(), + 'is_non_preview_user' => is_user_logged_in() && ! Newspack_Popups::is_user_admin(), + 'config' => self::get_criteria_config(), ] ); } diff --git a/src/criteria/default/user-account.js b/src/criteria/default/user-account.js index 55e537899..0a86a190f 100644 --- a/src/criteria/default/user-account.js +++ b/src/criteria/default/user-account.js @@ -1,10 +1,11 @@ +/* globals newspackPopupsCriteria */ import { setMatchingFunction } from '../utils'; setMatchingFunction( 'user_account', ( config, { store } ) => { switch ( config.value ) { case 'with-account': - return store.get( 'reader' )?.email; + return newspackPopupsCriteria.is_non_preview_user || store.get( 'reader' )?.email; case 'without-account': - return ! store.get( 'reader' )?.email; + return ! newspackPopupsCriteria.is_non_preview_user && ! store.get( 'reader' )?.email; } } );