Dynamic Google Reviews Link Function

Hey Gang,

We’ve been trying to create a way to use a dynamic URL to add to a Bricks URL field to redirect users directly to the Google Reviews popup on Google Business. However, the echo: function we’re adding isn’t working properly. Any thoughts on this one?

// Bricks Builder>Reviews URL
function vf_fetch_google_review_url() {
    $google_place_id = get_field('office_info_google_api_settings_places_id', 'option');
    $business_name = get_field('office_info_business_name', 'option');
    $street = get_field('office_info_address_primary_group_street', 'option');
    $suite = get_field('office_info_address_primary_group_suite', 'option');
    $city = get_field('office_info_address_primary_group_city', 'option');
    $state = get_field('office_info_address_primary_group_state', 'option');
    $zipcode = get_field('office_info_address_primary_group_zipcode', 'option');

    if ($google_place_id) {
        return "https://www.google.com/maps/place/?q=place_id={$google_place_id}&review=1";
    }

    $address_parts = [];
    if ($business_name) $address_parts[] = urlencode($business_name);
    if ($street) $address_parts[] = urlencode($street);
    if ($suite) $address_parts[] = urlencode($suite);
    if ($city) $address_parts[] = urlencode($city);
    if ($state) $address_parts[] = urlencode($state);
    if ($zipcode) $address_parts[] = urlencode($zipcode);

    $formatted_address = implode('%2C+', $address_parts);
    return "https://www.google.com/search?hl=en-US&gl=us&q={$formatted_address}&review=1";
}

add_shortcode('vf_google_review_url', 'vf_fetch_google_review_url');```

Hey @FranklyCo,

in your code example you’re creating a custom shortcode.

How is this related to using echo: functions? And what does isn’t working properly exactly mean?

Best,

André