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_header_shortcode.php
Last active February 24, 2025 18:54
Ultimate Member customization. Shortcode that displays the header section of the Ultimate Member profile.
<?php
/**
* Shortcode that displays the profile header.
* Example: [um_profile_header form_id="7" user_id="1"]
*
* @global \wpdb $wpdb
*
* @param array $atts Shortcode attributes:
* - (int) form_id - profile form ID. The first profile form if blank.
@yuriinalivaiko
yuriinalivaiko / um_email_notification_unverify_user.php
Last active June 4, 2023 21:49
This code adds custom email template "Verified Users - Account is not verified E-mail" to be used in the "Ultimate Member - Verified Users" extension.
<?php
if ( ! function_exists( 'um_email_locate_template' ) ) {
/**
* Locate a template and return the path for inclusion.
*/
function um_email_locate_template( $template_name ) {
$blog_id = is_multisite() ? '/' . get_current_blog_id() : '';
$template = locate_template(
@yuriinalivaiko
yuriinalivaiko / custom_field_validation_user_email.php
Last active January 21, 2025 18:01
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 );
@yuriinalivaiko
yuriinalivaiko / um_message_send_on_enter.js
Created November 29, 2022 19:43
This code sends a private message when the user presses the ENTER key.
/**
* Send private message on ENTER.
* Add this code to your custom JS file.
*/
jQuery( document.body ).on( 'keypress', 'textarea.um_message_text', function ( event ) {
if ( event.keyCode && event.keyCode === 13 || event.which === 13 ) {
jQuery( event.target ).closest( '.um-message-footer' ).find( '.um-message-send' ).trigger( 'click' );
}
} );
@yuriinalivaiko
yuriinalivaiko / um_profile_menu.php
Created November 24, 2022 21:33
This code changes the profile menu layout to a "hamburger menu" view on mobile devices.
<?php
/**
* Display profile menu as a hamburger menu on mobile.
* Add this code to the file functions.php in the active theme directory.
*/
add_action( 'um_profile_menu', function(){
?>
<div class="um-profile-menu">
<button class="um-profile-nav-toggle um-profile-nav-item um-tip-n uimob800-show uimob500-show uimob340-show" onclick="jQuery(this).toggleClass('open');" title="Profile Menu"><i class="um-faicon-bars"></i></button>
@yuriinalivaiko
yuriinalivaiko / um_login_redirect_url.php
Created November 6, 2022 16:59
Hook um_login_redirect_url
<?php
/**
* Hook: um_login_redirect_url
*
* Type: filter
*
* Description: Change redirect URL after successful login.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/um-actions-login.php#L258
@yuriinalivaiko
yuriinalivaiko / um_after_everything_output.php
Created November 6, 2022 16:34
Hook um_after_everything_output
<?php
/**
* Hook: um_after_everything_output
*
* Type: action
*
* Description: Fires after the form shortcode is loaded.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-shortcodes.php#L819
@yuriinalivaiko
yuriinalivaiko / um_after_form.php
Created November 6, 2022 16:22
Hook um_after_form
<?php
/**
* Hook: um_after_form
*
* Type: action
*
* Description: Fires before the closing tag in the form.
* May be used to display custom content in the form footer.
*
@yuriinalivaiko
yuriinalivaiko / um_after_mode_fields.php
Created November 6, 2022 16:10
Hook um_after_{$mode}_fields
<?php
/**
* Hook: um_after_{$mode}_fields
*
* Type: action
*
* Description: Fires after the form fields.
* May be used to display custom content after form fields or add hidden fields.
*