Skip to content

Commit

Permalink
fix: check for non-preview logged in user on account criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe committed Sep 13, 2024
1 parent 0af2f6a commit ca64f98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion includes/class-newspack-popups-criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/criteria/default/user-account.js
Original file line number Diff line number Diff line change
@@ -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;
}
} );

0 comments on commit ca64f98

Please sign in to comment.