Skip to content

Commit 95030d4

Browse files
authored
Merge pull request #406 from dwanjuki/popup-builder-disable-popups-members
Add disable Popup Builder popups for members
2 parents acaf6b7 + 823d640 commit 95030d4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Disable Popup Builder popups if the user has a membership level.
4+
*
5+
* Popup Builder is a plugin available in the WordPress.org Repo here:
6+
* https://wordpress.org/plugins/popup-builder/
7+
*
8+
* title: Disable Popup Builder popups if the user has a membership level.
9+
* layout: snippet
10+
* collection: integration-compatibility
11+
* category: content, popup-builder
12+
* link: https://www.paidmembershipspro.com/membership-logic-enable-disable-popups-popup-maker-popups-optinmonster/
13+
*
14+
* You can add this recipe to your site by creating a custom plugin
15+
* or using the Code Snippets plugin available for free in the WordPress repository.
16+
* Read this companion article for step-by-step directions on either method.
17+
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
18+
*/
19+
function my_pmpro_pub_disable_popups_for_members( $popup ) {
20+
// Bail if the user has a membership level.
21+
if ( function_exists( 'pmpro_hasMembershipLevel' ) && ! pmpro_hasMembershipLevel() ) {
22+
return $popup;
23+
}
24+
25+
// Popups with these IDs will be disabled for members.
26+
$non_member_popup_ids = array( 123, 335 );
27+
28+
// Disable popup.
29+
if ( in_array( $popup['id'], $non_member_popup_ids ) ) {
30+
$popup['status'] = false;
31+
}
32+
33+
return $popup;
34+
}
35+
add_filter( 'sgpbOtherConditions', 'my_pmpro_pub_disable_popups_for_members' );

0 commit comments

Comments
 (0)