Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um-profile-menu-vertical.css
Last active January 16, 2025 11:42
Ultimate Member customization. Make the profile menu vertical.
/**
* Make the profile menu vertical
*/
.um-profile:not(.uimob340) .um-form {
display: table;
}
.um-profile:not(.uimob340) .um-form .um-profile-nav,
.um-profile:not(.uimob340) .um-form .um-profile-body {
box-sizing: border-box;
margin-top: 0px !important;
@yuriinalivaiko
yuriinalivaiko / um_email__alter_recipient.php
Created January 15, 2025 12:29
Ultimate Member customization. Change the recipient for the "Account Needs Review Notification" email depending on the account role.
<?php
// Set a role admin email address for the "Account Needs Review Notification" email.
add_action( 'um_before_email_notification_sending', function( $email, $template ) {
if ( 'notification_review' === $template ) {
$role = um_user( 'role' );
// role admins.
$role_admins = array(
'subscriber' => '[email protected]',
@yuriinalivaiko
yuriinalivaiko / um_profile_role_specific_redirect.php
Created January 6, 2025 11:25
Ultimate Member customization. Redirect to Account page if the profile is not specific for the profile owner role.
<?php
// Redirect from the empty profile to Account.
add_filter( 'um_ultimatemember_shortcode_disable_singleton', function( $disable, $args ) {
if ( ! empty( $args['form_id'] ) ) {
$post_data = UM()->query()->post_data( $args['form_id'] );
$form_data = array_map( 'maybe_unserialize', $post_data );
$args = array_merge( $args, $form_data );
}
if ( 'profile' === $args['mode'] && ! empty( $args['use_custom_settings'] ) && ! empty( $args['role'] ) ) {
@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 December 19, 2024 12:50
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 December 12, 2024 17:53
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
Created December 9, 2024 18:44
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 March 27, 2025 21:13
Example. Choices Callback Feature. 4 related dropdowns.
<?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;">