Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um_choices_callback.php
Last active May 17, 2025 13:12
Ultimate Member documentation. Article: Choices Callback and Parent Option features. Example: Three dropdown fields linked using the Parent Option setting.
<?php
// Continent field.
function custom_continent_choices_callback() {
// choices array.
$options = array(
"africa" => "Africa",
"america" => "America",
"eurasia" => "Eurasia",
@yuriinalivaiko
yuriinalivaiko / um_display_all_form_errors.php
Created December 6, 2024 19:00
Display all form errors in the popup.
<?php
/**
* Display all form errors in the popup.
*/
add_action( 'um_after_form', function () {
if ( ! empty( UM()->form()->errors ) ) {
$error_text = implode( '<br>', UM()->form()->errors );
?>
<div id="um_form_errors" style="display:none;">
@yuriinalivaiko
yuriinalivaiko / um_delete_field.php
Created December 2, 2024 12:44
Remove the glitch field from the Ultimate Member form
<?php
// Set a field you want to remove here.
$meta_key = 'um_number_graduation';
function um_delete_field( $meta_key ) {
global $wpdb;
// Remove the field.
UM()->fields()->delete_field_from_db( $meta_key );
@yuriinalivaiko
yuriinalivaiko / um-activity-font-size.css
Last active January 13, 2025 11:58
Enlarge the font size in the activity wall of the "Ultimate Member - Social Activity" plugin.
/**
* Enlarge the font size in the activity wall.
*
* Add this file to the theme directory.
*/
.um-activity-wall .um-activity-head,
.um-activity .um-activity-head {
font-size: 14px; /* original 12px */
}
.um-activity-wall .um-activity-ticon,
@yuriinalivaiko
yuriinalivaiko / um_groups_autodelete.php
Last active May 13, 2025 18:32
Code snippets for the "Groups" extension
<?php
// Delete group discussion posts after 6 months.
add_action( 'um_daily_scheduled_events', 'um_groups_autodelete' );
function um_groups_autodelete() {
$args = array(
'post_type' => 'um_groups_discussion',
'fields' => 'ids',
'numberposts' => -1,
<?php
/**
* Hook: um_after_email_notification_sending
*
* Type: action
*
* Description: Fires after sending an email notification.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L456
@yuriinalivaiko
yuriinalivaiko / um_grouped_filters.php
Last active March 14, 2024 22:13
This code adds custom filters to the member directory of the Ultimate Member plugin. These filters are grouped - one filter searches in multiple fields.
<?php
/**
* Add custom grouped filters to the member directory.
*
* Add filters you need to this array. Every filter is an array where:
* - key Filter key. Any valid string key.
* - type Filter type. Accepts: 'text', 'select', 'slider', 'datepicker', 'timepicker'.
* - label Filter label (used as the filter placeholder).
* - fields An array of usermeta keys. Filter searches a value in these usermeta.
@yuriinalivaiko
yuriinalivaiko / my_template_tags.php
Last active May 17, 2025 13:16
Ultimate Member customization. Add custom email placeholders.
<?php
// Add role-specific content to the email template.
add_filter( 'um_template_tags_patterns_hook', 'my_template_tags_patterns', 10, 1 );
add_filter( 'um_template_tags_replaces_hook', 'my_template_tags_replaces', 10, 1 );
function my_template_tags_patterns( $search ) {
$search[] = '{welcome_content_for_subscriber}';
$search[] = '{welcome_content_for_customer}';
$search[] = '{welcome_content_for_um_member}';
return $search;
@yuriinalivaiko
yuriinalivaiko / um_activity_get_download_link_direct.php
Last active February 25, 2025 21:09
Code snippets for the "Social Activity" extension
@yuriinalivaiko
yuriinalivaiko / um_fix_selectWoo_conflict.php
Last active February 4, 2025 11:30
Code snippets for the "WooCommerce" extension
<?php
// Enqueue the "select2" script earlier to avoid a conflict with "selectWoo".
add_action( 'admin_enqueue_scripts', 'um_fix_selectWoo_conflict' );
add_action( 'wp_enqueue_scripts', 'um_fix_selectWoo_conflict' );
function um_fix_selectWoo_conflict() {
if ( wp_script_is( 'select2' ) && wp_script_is( 'selectWoo' ) ) {
$wp_scripts = wp_scripts();
if ( ! in_array( 'select2', $wp_scripts->queue, true ) && isset( $wp_scripts->registered[ 'select2' ] ) ) {
array_unshift( $wp_scripts->queue, 'select2' );