Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active October 26, 2023 11:32
Show Gist options
  • Save yuriinalivaiko/0c1be7b92c85c49b785a7169d20f6b55 to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/0c1be7b92c85c49b785a7169d20f6b55 to your computer and use it in GitHub Desktop.
This code snippet changes the map marker in the User Locations extension.
<?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 );
@yuriinalivaiko
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment