Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um_account_custom_fields.php
Last active November 23, 2024 12:21
This code snippet adds fields to the main Account tab.
<?php
// Add pre-defined fields to the main Account tab.
function um_account_tab_general_fields( $args, $shortcode_args ) {
// Fields Meta Keys.
$args .= ',birth_date';
$args .= ',country';
$args .= ',languages';
@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_custom_social_fields.php
Last active July 7, 2023 13:18
This code snippet adds a few custom social fields. You can use this example to add more custom social fields.
<?php
/**
* Add more social fields.
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'um_predefined_fields_hook', function( $predefined_fields ) {
$predefined_fields['pinterest'] = array(
'title' => __( 'Pinterest', 'ultimate-member' ),
@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 / 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.
@yuriinalivaiko
yuriinalivaiko / um_custom_validate_birth_date.php
Last active October 6, 2022 19:34
This code snippet restricts registration for under 18 years old using the custom validation applied to the Birth Date field. You can add this code to the functions.php file in the active theme directory.
<?php
/**
* Restrict registration for under 18 years old.
*
* @param array $args Form Arguments.
*/
function um_custom_validate_birth_date( $args ) {
if ( ! empty( $args['birth_date'] ) ) {
// Birth date as a Unix timestamp.
@yuriinalivaiko
yuriinalivaiko / um_user_locations_map_args_customize_03.php
Last active February 4, 2025 10:43
This code snippet customizes the map zooming and bounds. Add this code to the functions.php file in the theme directory.
<?php
/**
* Restricting Map Bounds and Zoom.
*/
add_action( 'wp_footer', function () {
?><script type="text/javascript">
function um_user_locations_customize_03 ( args, hash, directory ) {
args.center = {
@yuriinalivaiko
yuriinalivaiko / um_add_video_file_types.php
Last active November 11, 2023 15:50
This code snippet extends the "File upload" field type to add video formats. An array of supported video formats: 'mp4', 'm4v', 'webm', 'ogv', 'flv'.
<?php
/**
* Allow to upload video files via the "File Upload" field type.
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'um_allowed_file_types', 'um_add_video_file_types' );
add_filter( 'um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file_video', 101, 2 );
/**