|
/ Documentation /Developers/ How to Add Custom Conditions to Display a Call-to-action?

How to Add Custom Conditions to Display a Call-to-action?

Description

The cp_pro_target_page_settings filter allows adding custom conditions to display your design.

Usage

/**
 * Callback function to add more conditions while displaying popup
 *
 * @param bool $display
 * @param string $style_id
 * @return bool $display
 */
function your_callback_function( $display, $style_id ) {
 
    // Replace style id with your style ID
    if( $style_id == '23' ) {
 
       // your custom logic
    }
 
    return $display;
}
add_filter( 'cp_pro_target_page_settings', 'your_callback_function', 10, 3 );

Parameters

  • $display: (bool) value for displaying popup
  • $style_id: ( Int ) ID of style

Example

/**
 * Display style only to users with author role
 */
function check_user_role( $display, $style_id ) {
 
   // Replace style id with your style ID
   if( $style_id == '18' ) {
 
    if( is_user_logged_in() ) {

        // get current user role
        $current_user = new WP_User(wp_get_current_user());
        $user_roles = $current_user->roles;
 
       if( in_array( "author", $user_roles ) ) {
          $display = true;
       } else {
          $display = false;
       }
    } else {
 
       // hide style for non logged in users
       $display = false;
    }
  }
 
  return $display;
}
add_filter( 'cp_pro_target_page_settings', 'check_user_role', 10, 3 );

 

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page

Compare Convert Pro with...

29439
29440
Scroll to Top