SOLVED: How to display popup globally based on pods/acf checkbox (true/false for ACF) being ticked

Hello,

I’m trying to have a popup display only when a pods checkbox is ticked. I have set the popup conditions to show on the entire website as below


image


The condition as seen below is set to show if the custom field (is_the_campaign_active) is equal to 1 which I understand is the boolean value for true in pods but nothing happens (I have set the condition on the main div in the popup template)


image


As an aside I also tried to follow the solution in a previous forum post → ACF Value not usable in element conditions where you add a function and using echo to compare but that also doesn’t work.

I searched the forum and Facebook groups to the best of my ability but couldn’t find a solution. Any guidance on how to solve this is truly appreciated. Thanks.

After a lot of back and forth with my good friend, co-pilot. I have been able to get a working solution for this. I’m posting it here for anyone who faces this problem and for the experts to provide input on the methodology.

For pods
Add this function to your code editor or functions.php

function get_pods_popup_status() {
    $post_id = xxxxx; // Replace with your actual CPT post ID that has the Pods field

    $pod = pods('your_cpt_slug', $post_id); // Replace 'your_cpt_slug' with your actual CPT slug
    if (!$pod) return 'false'; // Ensure the Pods instance exists

    $popup_status = $pod->field('show_popup'); // Replace 'show_popup' with your actual Pods field name

    return ($popup_status == 1) ? 'true' : 'false'; // Returns 'true' if checked, 'false' if unchecked
}

Then on the conditions of the popup add the ```{echo: get_pods_popup_status}``` and compare it against the value "true" or "false".

For ACF
The function changes slightly to

function get_acf_popup_status() {
    $post_id = xxxx; // Replace with an actual post ID that has the ACF field

    $popup_status = get_field('show_popup', $post_id);
    return ($popup_status == 1) ? 'true' : 'false';
}

The rest stays the same.