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_private_content_edit.php
Last active April 6, 2022 11:52
This code snippet adds a link "Edit private content" to the profile under the private content.
<?php
/**
* Add a button to the member profile that an admin can click so they are redirected to the private content of the relevant member
* @author Ultimate Member support <support@ultimatemember.com>
* @since 2022-03-17
* @see #59138
*/
add_action( 'um_profile_content_private_content', function( $args ) {
if ( is_user_logged_in() && current_user_can( 'administrator' ) && current_user_can( 'edit_user', um_profile_id() ) ) {
@yuriinalivaiko
yuriinalivaiko / um_member_directory_notme.php
Last active July 10, 2022 11:08
This code snippet prevents members from being able to see themselves in the member directory.
<?php
/**
* Prevent members from being able to see themselves in the member directory.
* Add this code to the file functions.php in the active theme directory.
*/
function um_pre_users_query_notme( $directory ) {
if ( is_user_logged_in() ) {
$directory->where_clauses[] = 'u.ID != ' . get_current_user_id();
@yuriinalivaiko
yuriinalivaiko / um_profile_completeness_complete_profile_redirect.php
Last active July 10, 2022 11:12
Customize redirection after the profile is completed in the widget "Ultimate Member - Complete your Profile".
<?php
/**
* Redirection after profile is completed
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'um_profile_completeness_complete_profile_redirect', function( $redirect, $user_id, $result ) {
if ( is_array( $result ) && absint( $result['progress'] ) >= absint( $result['req_progress'] ) ) {
$redirect = home_url();
@yuriinalivaiko
yuriinalivaiko / js_code_snippet.js
Last active August 3, 2022 10:59
Use one of these code snippets to fix a form view in popup. This example uses a button selector for the Elementor popup. Change a button selector to use this code with another popup plugin.
/**
* A code snippet that triggers the "resize" once the popup is open.
* Add this code to your custom JS file.
*/
jQuery( '.elementor-button[href^="#elementor-action"]' ).on( 'click', function () {
setTimeout( function() {
jQuery( window ).trigger( 'resize' );
}, 100 );
} );
@yuriinalivaiko
yuriinalivaiko / my_before_password_form_is_loaded.php
Last active September 7, 2022 12:07
This gist provides examples and description for hooks used by the Ultimate Member plugin on password reset process.
<?php
/**
* Description: Fires before the password reset form shortcode is loaded.
*
* Hook: um_before_password_form_is_loaded
*
* Type: action
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-password.php#LC239
@yuriinalivaiko
yuriinalivaiko / um_member_directory_filter_slider_limits.php
Created September 17, 2022 13:43
This code snippet changes limits (min and max) in the range filter in the UM member directory.
<?php
/**
* Use "Minimum Number" and "Maximum Number" options as the range filter limits.
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'um_member_directory_filter_slider_common', function( $range, $directory_data, $filter ) {
$field_data = UM()->fields()->get_field( $filter );
if ( is_array( $field_data ) && isset( $field_data['min'] ) && isset( $field_data['max'] ) ) {
@yuriinalivaiko
yuriinalivaiko / um_add_user_to_all_blogs.php
Created September 19, 2022 11:15
This code snippet adds registered users to all subsites.
<?php
/**
* When users register on the main site they will be added to all subsites.
*
* @param int $user_id User ID.
* @param array $args Form data.
*/
function um_add_user_to_all_blogs( $user_id, $args ) {
@yuriinalivaiko
yuriinalivaiko / jb_post_thumbnail_size.php
Last active October 6, 2022 17:53
This code snippet changes the job's company logo size in the JobBoardWP plugin.
<?php
/**
* Change the job's company logo size. Get rid of the cropped square logo. Use true logo image ratio.
* Add this code to the file functions.php in the active theme directory.
*/
/**
* Change the company logo size.
*
@yuriinalivaiko
yuriinalivaiko / member_directory_columns.css
Created October 6, 2022 17:58
This CSS code snippet changes the grid layout of the member directory in the Ultimate Member plugin to 4 columns. This snippet influences only large screens where the member directory is wider than 960px.
/* member directory grid with 4 columns */
.um-directory:not(.uimob340):not(.uimob500):not(.uimob800):not(.uimob960) .um-members-wrapper .um-members.um-members-grid .um-member {
width: 21%;
}
@yuriinalivaiko
yuriinalivaiko / um_field_value_show_default.php
Last active October 6, 2022 18:46
This code snippet displays the default value if the field value is empty in the profile view mode. You can add this code to the functions.php file in the active theme directory.
<?php
/**
* Display default value if the field value is empty in the profile view mode.
*
* @param string $value Field Value.
* @param string $default Field Default Value.
* @param string $key Field Key.
* @param string $type Field Type.
* @param array $data Field Data.