wpgmp_before_map - WP Maps Pro

15000+ live websites are using this google maps wordpress plugin.

wpgmp_before_map

This hook in the WP Maps Pro plugin allows developers to insert custom HTML before the map element. It is triggered before the map is rendered on the frontend, providing an opportunity to customize the content or layout directly above the map.

Usage

Developers can implement this hook in their theme’s functions.php file or within a custom plugin. It is essential to ensure that the code is efficient and does not interfere with the map’s functionality. Consider using this hook to add additional information, instructions, or custom controls related to the map.

Example 1

Add a custom title above the map to provide context or instructions to users.

add_action('wpgmp_before_map', function($map) {
    echo '<h3>Explore Our Locations</h3>';
}, 10, 1);

Example 2

Insert a custom advertisement banner above the map to promote related services or offers.

add_action('wpgmp_before_map', function($map) {
    echo '<div class="map-ad-banner">Check out our latest travel guides!</div>';
}, 10, 1);

Example 3

Display user-specific information by accessing user data before the map is displayed.

add_action('wpgmp_before_map', function($map) {
    if(is_user_logged_in()) {
        $current_user = wp_get_current_user();
        echo '<p>Welcome back, ' . esc_html($current_user->display_name) . '!</p>';
    }
}, 10, 1);

Tip: When using this hook, ensure that any HTML output is properly sanitized and escaped to prevent security vulnerabilities, such as XSS attacks.

Install Plugin Now!

Buy this plugin exclusively on CodeCanyon! You’ll get free updates, full support, and if you’re not satisfied, we’ve got you covered with a 30-day money-back guarantee.