Home Forums ACF PRO Using ACF with GeoIP Detect Plugin


Using ACF with GeoIP Detect Plugin

  • Hi,

    I’m still learning PHP and am somewhat of a noob. What I’m trying to do is show different content depending on whether the user is based in the US using the GeoIP Detect plugin. I have some working code, which is great. However, I need it to work somewhat differently.

    This is the code that works and displays the fields fine

    <?php $userInfo = geoip_detect2_get_info_from_current_ip();
    if ($userInfo->country->isoCode == 'US'){
    else {

    If tried a few ways but nothing seems to work. Here’s something I’ve tried but not no avail.

    <?php $userInfo = geoip_detect2_get_info_from_current_ip() : ?>
    <?php if ($userInfo->country->isoCode == 'US') : ?>
    From <span class="price">$<?php the_field('package_price_us'); ?> /mo</li>
    <?php else : ?>
    From <span class="price">£<?php the_field('package_price');} ?></span> /mo
    <?php endif; ?>

    Any help would be greatly appreciated it.

  • Oh man, just tried something else which was so easy that I just thought it wouldn’t work but I gave it a try and it works.

    Thanks anyways 😀

    <?php $userInfo = geoip_detect2_get_info_from_current_ip();
    if ($userInfo->country->isoCode == 'US'){
    echo "From <span class='price'>$"; the_sub_field('package_price_us'); echo "</span>/mth*";}
    else {
    echo "From <span class='price'>£"; the_sub_field('package_price'); echo "</span>/mth*";}
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Using ACF with GeoIP Detect Plugin’ is closed to new replies.