Gravity Forms – Disable and Remove the “Map It” Link

In the Gravity Forms generated emails, if your form has a “address” field the email notification generated by using something like {all_fields} will have a “Map It” link associated with the address, which will open Google Maps.

Add this code to your theme’s functions.php file to disable / remove the “Map It” link from the email notification.

// code courtesy of https://techblog.willshouse.com/?p=5249
add_filter("gform_pre_send_email", array($this,'gform_pre_send_email'));
function gform_pre_send_email($email)
{

    // attempt to match the link using a regular expression
    $test = preg_replace("#\<a [^>]+?\>Map It[^>]+\>#i", '', $email["message"]);
    // if the result is not empty / blank, use it to replace the original html
    if(trim($test))
    {
        $email["message"] = $test;
    }

    return $email;

}

If you want to hide the “map it” link from the HTML that is displayed on a webpage ( if you confirmation has the {all_fields} merge replacement in it ) then you can add some CSS like this:

<style>
a.map-it-link
{
    display: none;
}
</style></a>

Related Posts:

  • No Related Posts
This entry was posted in Tech Tips, Web Development and tagged , . Bookmark the permalink.

2 Responses to Gravity Forms – Disable and Remove the “Map It” Link

  1. Mark says:

    Do think there is a way to make it open in another mapping program. I use Igo primo on my van sat nav. It would be pretty amazing to be able to open the emails on the sat nav unit and it mapped in the Igo navigation.

    Thanks

  2. Jonathan Joosten says:

    It didn’t work, but this solution may work better:

    add_filter( ‘gravityview_map_link’, ‘gravityview_change_map_link’, 10, 3 ); function gravityview_change_map_link( $link, $address, $url ) { return ”; }

Leave a Reply

Your email address will not be published. Required fields are marked *