Skip to content

Instantly share code, notes, and snippets.

@danieliser
Last active May 14, 2018 18:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieliser/32aff18fbf245c58c7fe to your computer and use it in GitHub Desktop.
Save danieliser/32aff18fbf245c58c7fe to your computer and use it in GitHub Desktop.
Custom Targeting using popmake_popup_is_loadable filter.
<?php
function my_custom_popup_trigger( $is_loadable, $popup_id ) {
if ( $popup_id == 123 ) {
if ( $my_condition == true ) {
$is_loadable = true;
}
else {
$is_loadable = false
}
}
return $is_loadable;
}
add_filter( 'popmake_popup_is_loadable', 'my_custom_popup_trigger', 1000, 2 );
@rwkyyy
Copy link

rwkyyy commented Nov 30, 2015

on WP 4.3.1, plugin version 1.9 is showing:
Warning: Missing argument 2 for popup_trigger()

also, the else is not closed with ;

@danieliser
Copy link
Author

Updated to deal with missing argument issue.

@elvinlee
Copy link

Hi,

With latest version 1.4.5, if I have use filter to set condition and trigger, I still need to set condition and trigger in popup or ignore it?

function user_logged_in_trigger( $is_loadable, $popup_id ) { if ( is_page( 8 ) ) { if ( is_user_logged_in() ) { if ( $popup_id == '194' ) { $is_loadable = true; } } else { if ( $popup_id == '195' ) { $is_loadable = true; } } } return $is_loadable; } add_filter( 'popmake_popup_is_loadable', 'user_logged_in_trigger', 1000, 4 );

@danieliser
Copy link
Author

@elvinlee - You may still want to add page level targeting but if you want it sitewide then no you don't need conditions.

But the filter above only applies to conditions not triggers so you still need to add your triggers to open it the way you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment