wpgmp_map_data - WP Maps Pro

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

wpgmp_map_data

This hook allows developers to modify the map data before any processing occurs in the WP Maps Pro plugin. It is triggered before the map data is processed, enabling customization of map settings and features at runtime.

Usage

Developers can implement this hook in their theme’s functions.php file or a custom plugin to adjust the map data dynamically. This is especially useful for altering map settings based on specific conditions, user roles, or other runtime variables.

Example 1

Modify the map’s zoom level based on the current user’s role.

add_filter('wpgmp_map_data', 'customize_map_zoom_level', 10, 2);

function customize_map_zoom_level($map_data, $map) {
    if (current_user_can('administrator')) {
        $map_data['map_zoom_level'] = '10'; // Set higher zoom for administrators
    }
    return $map_data;
}

Example 2

Change the map type to ‘SATELLITE’ for a specific map ID.

add_filter('wpgmp_map_data', 'set_satellite_map_type', 10, 2);

function set_satellite_map_type($map_data, $map) {
    if ($map_data['map_id'] == '10') {
        $map_data['map_type'] = 'SATELLITE';
    }
    return $map_data;
}

Example 3

Add custom CSS to the map’s settings dynamically.

add_filter('wpgmp_map_data', 'add_custom_map_css', 10, 2);

function add_custom_map_css($map_data, $map) {
    $map_data['wpgmp_custom_css'] .= '.custom-marker { background-color: #ff0000; }';
    return $map_data;
}

Tip: Always validate and sanitize any input data when using hooks to ensure security and prevent vulnerabilities in your WordPress site.

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.