Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / hide_unapproved_members.php
Last active November 1, 2022 10:34
This code snippet hides unapproved members in the members directory.
<?php
/**
* Hide unapproved members in the members directory for everybody.
*/
add_action( 'um_member_directory_before_query', function() {
add_filter( 'um_user_permissions_filter', 'custom_disable_permission_can_edit_everyone' );
} );
function custom_disable_permission_can_edit_everyone( $permissions ) {
$permissions['can_edit_everyone'] = false;
@yuriinalivaiko
yuriinalivaiko / um_add_vcard_file_types.php
Last active October 28, 2022 13:48
This code snippet extends the "File upload" field type to allow the vCard (also known as VCF) file types.
<?php
/**
* Allow to upload vCard files via the "File Upload" field type.
* Add this code to the file functions.php in the active theme directory.
*/
function um_add_vcard_file_types( $allowed_types ) {
if( is_array( $allowed_types ) ) {
$vcard_types = array(
@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 );
/**
@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_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_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 / 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_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 / 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_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' ),