Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um_validate_email_domain.php
Created December 1, 2025 11:41
Ultimate Member customization. Block registration that contains specific strings in the email domain.
<?php
// Custom validation for the "E-mail Address" field on registration.
// Block registration that contains specific strings in the email domain.
function um_validate_email_domain( $args ) {
// List blocked email domains here (entire domain or a part of it).
$blocked_email_domains = array(
'vovk.store'
);
@yuriinalivaiko
yuriinalivaiko / um_profile_form_shortcode.php
Last active December 11, 2025 19:49
Ultimate Member customization. Shortcode that displays the form section of the Ultimate Member profile.
<?php
/**
* Builds the profile form shortcode output.
*
* The supported attributes for the shortcode are 'form_id'.
* Example 1: [um_profile_form]
* Example 2: [um_profile_form form_id="1740"]
*
* @param array $atts {
@yuriinalivaiko
yuriinalivaiko / functions.php
Last active November 13, 2025 17:26
Code snippet for the ticket #107666
<?php
/**
* Outputs Social Media Icons.
*/
if ( ! function_exists( 'um_theme_social_menu' ) ) {
function um_theme_social_menu() {
global $defaults;
@yuriinalivaiko
yuriinalivaiko / um_woo_product_settings_to_subscription.php
Last active October 31, 2025 11:19
Code snippets for the "WooCommerce" extension
<?php
// Update the role configuration for existing subscriptions when the related product-subscription is updated.
if ( is_plugin_active( 'um-woocommerce/um-woocommerce.php' ) && function_exists( 'wcs_get_subscription' ) ) {
add_action( 'save_post', 'um_woo_product_settings_to_subscriptions', 20, 2 );
}
/**
* Updates saved role settings in existing subscriptions using the product's role settings.
*
@yuriinalivaiko
yuriinalivaiko / um_user_locations_map_args_customize_06.php
Created October 16, 2025 20:47
This code snippet replaces the full address with the city name in the User Location field.
<?php
/**
* Change the user location field value. Save only a city.
*/
add_action( 'wp_footer', function () {
?><script type="text/javascript">
var currentLocationField;
jQuery( '.um_user_location_g_autocomplete' ).on( 'click', function() {
currentLocationField = this;
@yuriinalivaiko
yuriinalivaiko / um_user_locations_alter_scripts.php
Last active May 17, 2025 13:29
Code snippets for the "User Locations" extension
<?php
/**
* Defer scripts of the "Ultimate Member - User Locations" extension.
*
* @link https://developer.wordpress.org/reference/classes/wp_scripts/add_data/
* @global WP_Scripts $wp_scripts
*/
function um_user_locations_alter_scripts() {
global $wp_scripts;
@yuriinalivaiko
yuriinalivaiko / um_member_directory_filter_select_options_sorted.php
Created May 17, 2025 13:24
Ultimate Member customization. Code snippets for the member directory.
<?php
// Sort member directory filter options by values.
add_filter( 'um_member_directory_filter_select_options_sorted', function( $options, $attrs ) {
asort( $options );
return $options;
}, 10, 2 );
@yuriinalivaiko
yuriinalivaiko / um_messaging_autodelete.php
Last active May 16, 2025 12:15
Code snippets for the "Private Messages" extension
<?php
// Delete private messages after 6 months.
add_action( 'um_daily_scheduled_events', 'um_messaging_autodelete' );
function um_messaging_autodelete() {
global $wpdb;
$timestamp = strtotime( '6 months ago');
$sql = $wpdb->prepare(
@yuriinalivaiko
yuriinalivaiko / new_service.php
Last active April 11, 2025 20:03
Ticket 97389: Integration of Google Maps API for Custom Radius-Based Notification System
<?php
// Add custom email notifications.
add_filter( 'um_email_notifications', 'onemec_email_notifications', 10, 1 );
// Call action when a new Job is published.
add_action( 'jb_job_published', 'onemec_job_submitted', 10, 2 );
/**
* Extend Ultimate Member email notifications.
@yuriinalivaiko
yuriinalivaiko / um_get_field_block.php
Created April 10, 2025 16:51
Ultimate Member customization. Apply shortcodes in the "Content Block" field.
<?php
// apply shortcodes in the "Content Block" field.
add_filter( 'um_get_field_block', function( $data ) {
if ( array_key_exists( 'content', $data ) ) {
$data['content'] = apply_shortcodes( $data['content'] );
}
return $data;
} );