Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um_followers__add_on_registration.php
Last active February 3, 2025 13:42
Code snippets for the "Followers" extension
<?php
// Automatically follow the brand profile on registration.
add_action( 'um_registration_set_extra_data', function( $user_id, $args ) {
if ( defined( 'um_followers_version' ) ) {
// all new members will "follow" this brand profile.
$brand_user_id = 1;
if ( UM()->Followers_API()->api()->can_follow( $brand_user_id, $user_id ) ) {
@yuriinalivaiko
yuriinalivaiko / um-verified-after-role-is-updated.php
Last active January 16, 2026 16:40
Code snippets for the "Verified Users" extension
<?php
// Apply the role's auto-verify feature when the role is changed manually.
if ( function_exists( 'um_after_user_role_is_updated' ) ) {
add_action( 'add_user_role', 'um_after_user_role_is_updated', 20, 2 );
add_action( 'set_user_role', 'um_after_user_role_is_updated', 20, 2 );
}
@yuriinalivaiko
yuriinalivaiko / um_conflicts_fix.php
Last active December 20, 2024 13:41
Disable conflicting plugins on UM pages.
<?php
/**
* Plugin Name: Ultimate Member - Conflicts Fix
* Description: Disable conflicting plugins on UM pages.
* Author: Ultimate Member support team
* Author URI: https://ultimatemember.com/support/
* Version: 1.0.0
*
* Add this code to the file /wp-content/mu-plugins/um_conflicts_fix.php
*/
@yuriinalivaiko
yuriinalivaiko / um_directory_grid_image.php
Last active May 17, 2025 13:06
Ultimate Member customization. Display custom image in the member directory grid.
<?php
/**
* Add custom image field into the variable "user" used to build member directory cards.
*/
add_filter( 'um_ajax_get_members_data', 'custom_um_ajax_get_members_data', 10, 3 );
function custom_um_ajax_get_members_data( $data_array, $user_id, $directory_data ) {
// Enter the field meta_key you need.
$key = 'um_image_upload';
@yuriinalivaiko
yuriinalivaiko / um_directory_grid_images.php
Last active May 17, 2025 13:06
Ultimate Member customization. Display custom images in the member directory grid.
<?php
/**
* Display custom images in the member directory grid.
*/
add_filter( 'um_ajax_get_members_data', function( $data_array, $user_id, $directory_data ) {
// List needed fields here.
$fields = array(
'um_image_upload',
@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 February 11, 2026 19:50
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,