Last active
October 26, 2023 11:32
-
-
Save yuriinalivaiko/0c1be7b92c85c49b785a7169d20f6b55 to your computer and use it in GitHub Desktop.
This code snippet changes the map marker in the User Locations extension.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change the map marker title and image. | |
*/ | |
add_action( 'wp_footer', function () { | |
?><script type="text/javascript"> | |
wp.hooks.addFilter('um_user_locations_marker_data', 'um_user_locations', function (marker_data, hash, userdata) { | |
// Change the map marker title. | |
marker_data.title = userdata.display_name; | |
// Replace the map marker image. | |
if ( 'object' === typeof marker_data.icon ) { | |
marker_data.icon.url = 'http://website.domain/wp-content/plugins/ultimate-member/assets/img/default_avatar.jpg?um_avatar_marker=1'; | |
} | |
return marker_data; | |
}, 20); | |
</script><?php | |
}, 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is a part of the article User Locations - Hooks
You can add this code to the
functions.php
file in the active theme directory. Skip the opening<?php
tag.