Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um_custom_button_in_profile.php
Last active December 13, 2024 12:31
Add a button (link) for each member in the member directory, and also add a button (link) to the user profile.
<?php
/**
* Change the $href variable to an URL that navigates to a page you need
* and change the $title variable to a button text you need
* then add this code to the functions.php file in the theme directory.
*/
// Add a custom button (link) on user profile.
function um_custom_button_in_profile( $args ) {
@yuriinalivaiko
yuriinalivaiko / um_wpseo_sitemaps_users.php
Last active June 16, 2023 18:59
This code snippet adds all approved users whose Ultimate Member profiles are public to the sitemap generated by Yoast SEO plugin.
<?php
/**
* Add all approved users whose Ultimate Member profiles are public to the sitemap.
*/
add_filter( 'wpseo_sitemap_entry', 'um_wpseo_sitemap_entry', 10, 3 );
add_filter( 'wpseo_sitemap_exclude_author', 'um_wpseo_sitemaps_users' );
/**
@yuriinalivaiko
yuriinalivaiko / um_user_locations_map_args_customize_05.php
Last active October 26, 2023 11:31
This code snippet uses the Map ID to customize the map styles in the User Locations extension.
<?php
/**
* Use Map ID to customize the user location map.
*/
add_action( 'wp_footer', function () {
?><script type="text/javascript">
function um_user_locations_customize_mapId( args, hash, directory ) {
args.mapId = 'YOUR_MAP_ID';
@yuriinalivaiko
yuriinalivaiko / um_user_locations_marker_data.php
Last active October 26, 2023 11:32
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.
@yuriinalivaiko
yuriinalivaiko / um_member_directory_disable_clustering.php
Last active October 26, 2023 11:30
This code snippet disables the map marker clustering in the User Locations extension.
<?php
/**
* Disable Clustering
*/
add_action( 'wp_footer', function () {
?><script type="text/javascript">
wp.hooks.addFilter( 'um_member_directory_disable_clustering', 'um_user_locations', function ( disableClustering, directory ) {
disableClustering = true;
return disableClustering;
@yuriinalivaiko
yuriinalivaiko / um_account_custom_tabs.php
Last active May 17, 2025 13:20
Ultimate Member documentation. Article: How to display custom fields in Account.
<?php
/**
* Add custom tabs.
*
* @param array $tabs Account tabs.
* @return array
*/
function um_account_custom_tabs( $tabs ) {
$tabs[ 150 ][ 'custom_tab_01' ] = array(
@yuriinalivaiko
yuriinalivaiko / um_profile_header_shortcode.php
Last active November 20, 2025 12:03
Ultimate Member customization. Shortcode that displays the header section of the Ultimate Member profile.
<?php
/**
* Builds the profile header shortcode output.
*
* The supported attributes for the shortcode are 'form_id', 'user_id'.
* Example 1: [um_profile_header]
* Example 2: [um_profile_header form_id="7" user_id="1"]
* Example 3: [um_profile_header form_id="7" user_id="get_current_user_id"]
*
@yuriinalivaiko
yuriinalivaiko / um_email_notification_unverify_user.php
Last active November 24, 2025 18:03
This code adds custom email template "Verified Users - Account is not verified" to be used in the "Ultimate Member - Verified Users" extension.
<?php
/**
* Add custom email template "Verified Users - Account is not verified".
*
* @param array $emails Emails list.
* @return array
*/
function um_email_notification_unverify_user( $emails ) {
@yuriinalivaiko
yuriinalivaiko / custom_field_validation_user_email.php
Last active June 18, 2025 06:37
Ultimate Member customization. Change error message for the "E-mail Address" field in the Registration form.
<?php
/**
* Custom validation and error message for the "E-mail Address" field.
*/
add_action( 'um_custom_field_validation_user_email_details', 'um_custom_validate_user_email_details', 999, 3 );
function um_custom_validate_user_email_details( $key, $array, $args ) {
if ( $key == 'user_email' && isset( $args['user_email'] ) ) {
if ( isset( UM()->form()->errors['user_email'] ) ) {
unset( UM()->form()->errors['user_email'] );
@yuriinalivaiko
yuriinalivaiko / um_custom_tags_patterns_group_comment.php
Created November 30, 2022 20:20
These code snippets add custom placeholders {post_content} and {comment_content} for the email notifications in the "Ultimate Member - Groups" extension.
<?php
/**
* Add custom placeholder {comment_content} for the "Groups - New comment" email template.
*/
add_action( 'um_groups_after_wall_comment_published', 'um_custom_tags_patterns_group_comment_on', 8, 4 );
add_action( 'um_groups_after_wall_comment_published', 'um_custom_tags_patterns_group_comment_off', 12, 4 );
function um_custom_tags_patterns_group_comment_on( $commentid, $comment_parent, $post_id, $user_id ){
$GLOBALS['um_groups_after_wall_comment_published_id'] = $commentid;
add_filter( 'um_template_tags_patterns_hook', 'um_custom_tags_patterns_group_comment', 10, 1 );