DEAL ENDS IN:

SPRING SALE!

UP TO 35% OFF!

GET IT NOW

Developers FAQ

  • Can I use If-So with the Advanced Custom Fields (ACF) WordPress plugin?

    Yes. You can use If-So with the ACF plugin.


    The first step is to create an If-So trigger and paste its shortcode inside the custom field. Since Advanced Custom Fields do not render shortcodes by default, next you’ll need to add the following filters to your functions.php file.  Please feel free to contact us if you need help with that.

    If you’d like to use If-So inside a Text field:
    add_filter(‘acf/format_value/type=text, ‘do_shortcode’);

    If you’d like to use If-So inside a Text Area field:
    add_filter(‘acf/format_value/type=textarea’, ‘do_shortcode’);

  • Can I get the geo data detected by If-So?

    If-So utilizes an IP-to-location database to determine the user’s location. You can use the geo data detected by If-So for any purpose by implementing the following code:

    require_once(IFSO_PLUGIN_BASE_DIR. 'services/geolocation-service/geolocation-service.class.php');
    $geo_data = \IfSo\Services\GeolocationService\GeolocationService::get_instance()->get_user_location();

    Keep in mind that IP-to-location services (any service, not just ours) are not always 100% accurate. Learn more about IP-to-location services and how they work.

    Want to capture the user’s location using JavaScript? Click here

  • Is there a way to capture the user's country in JavaScript?

    Yes, you can capture the user’s country in JavaScript by using the following PHP code in your theme’s functions.php file. This code fetches the user’s geolocation data and sets it as a JavaScript variable:

    phpCopy codeadd_action('wp_enqueue_scripts', function(){
        if(!defined('IFSO_PLUGIN_BASE_DIR')) return;
        require_once(IFSO_PLUGIN_BASE_DIR. 'services/geolocation-service/geolocation-service.class.php');
        $geo_data = \IfSo\Services\GeolocationService\GeolocationService::get_instance()->get_user_location();
        $ifso_country = !empty($geo_data->get('countryCode')) ? $geo_data->get('countryCode') : '';
        if(function_exists('wp_add_inline_script'))
            wp_add_inline_script('if-so',"var ifso_country = '{$ifso_country}';",'after');
    });
    

    This code will make the user’s country available as a variable named ifso_country in your JavaScript. You can customize this code to capture other geolocation data, such as city or state, by adjusting the values in the code.

  • Can I embed a trigger directly in a page template?

    Yes, you can. Learn more.

  • How do I enable Ajax for a specific trigger that is embedded using PHP (for developers)?

    If you want to enable Ajax loading for a specific trigger that is embedded directly in the page template using a PHP code, you can use the “echo do_shortcode(‘…’);” function

     <?php echo do_shortcode(''); ?>
  • Are there any limitations when testing If-So in a local environment?

    The only limitation to keep in mind is that the geolocation service will not function properly. This means that dynamic content with geolocation conditions will be treated as if the condition is not met.

    If you wish to set location-based content and preview how it will appear to users when the condition is met, you can make use of the “testing mode” button. This feature enables you to force the display of the specified version, giving you a visual representation of the final result on your site.

    Do license activations in a local environment count toward the total number of license activations?

    Yes, but you have the flexibility to deactivate the license once the development is complete and activate it on another site of your choice.