wpgmp_accept_cookies - WP Maps Pro

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

wpgmp_accept_cookies

This hook in the WP Maps Pro plugin allows developers to customize the functionality related to accepting cookies before displaying the map. It is triggered before the map is shown and ensures that user consent is obtained for cookies.

Usage

Developers can implement this hook within their theme or plugin to alter or enhance the way cookies are managed before a map is displayed. This can be done by adding custom functions to modify behavior or integrate additional functionalities, such as logging or conditional display based on cookie acceptance.

Example 1

This example shows how to log a message when the cookie acceptance hook is triggered.

add_action('wpgmp_accept_cookies', function() {
    error_log('Map cookies have been accepted.');
});

Example 2

In this example, the hook is used to redirect users to a cookie policy page if they haven’t accepted cookies.

add_action('wpgmp_accept_cookies', function() {
    if (!isset($_COOKIE['maps_cookie_accepted'])) {
        wp_redirect(home_url('/cookie-policy'));
        exit;
    }
});

Example 3

This example demonstrates how to display a custom message to users who have accepted cookies.

add_action('wpgmp_accept_cookies', function() {
    if (isset($_COOKIE['maps_cookie_accepted'])) {
        echo '<div class="cookie-message">Thank you for accepting cookies. The map is now visible.</div>';
    }
});

Remember to always check if cookies are set and handle them securely, ensuring compliance with privacy regulations such as GDPR.

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.