Skip to content

Instantly share code, notes, and snippets.

@denisbaranov
denisbaranov / um_member_directory_disable_clustering.php
Last active September 18, 2021 12:03
You can find some code samples for using hooks in the extension User Locations
<?php
/**
* Disable Clustering
* You may add this code to the file functions.php in the active theme directory.
*
* @author Ultimate Member support <support@ultimatemember.com>
* @link https://ultimatemember.com/extensions/user-locations/
*/
add_action( 'wp_footer', function () {
@denisbaranov
denisbaranov / Add an image field into the profile card in the member directory.php
Last active February 7, 2021 17:08
​Special field types (files, images, etc.) can't be added into the profile card. Settings don't contain these fields. You can use your custom function attached to the filter "um_ajax_get_members_data" to add additional data into the variable "user".
<?php
/**
* This example shows how to add an image field into the variable "user" in the member directory.
*
* Change the variable $key - enter meta_key of the field you need.
* Add this code snippet to the end of the file functions.php in the active theme directory.
*
* @link Documentation https://docs.ultimatemember.com/
* @link Article https://docs.ultimatemember.com/article/1586-add-an-image-field-into-the-profile-card-in-the-member-directory
*/
@denisbaranov
denisbaranov / Block the email address by domain.php
Last active February 2, 2021 16:56
The following code requires users to register with a business email only and blocks popular email services, such as @gmail.com, @yahoo.com. ect. The code below requires a user email to be collected during registration.
<?php
/**
* This example shows how to validate the email address by domain on registration.
* The code below requires a user email to be collected during registration.
*
* Change the array $forbidden_email_domains - add or remove domains you need.
* Add this code snippet to the end of the file functions.php in the active theme directory.
*
* Ultimate Member documentation: https://docs.ultimatemember.com/
@denisbaranov
denisbaranov / um_grouped_filtes_custom.php
Last active February 12, 2023 17:59
This example shows how to group several filters in the Members Directory of the Ultimate Member (with the custom table for usermeta).
<?php
/**
* This example shows how to group several filters in the Members Directory of the Ultimate Member.
* For example there are three phone fields in the profile ("Phone", "Phone number", "Mobile Number"),
* but you want to use a single filter "Phone number" to filter by these three fields in the Member Directory.
*
* Note: This example works if the setting "Enable custom table for usermeta" is turned on.
* See the gist https://gist.github.com/denisbaranov/3631abb45a05d6cdfbb6a4b6a6862b4c otherwise.
*
@denisbaranov
denisbaranov / um_grouped_filtes.php
Last active February 12, 2023 17:59
This example shows how to group several filters in the Members Directory of the Ultimate Member.
<?php
/**
* This example shows how to group several filters in the Members Directory of the Ultimate Member.
* For example there are three phone fields in the profile ("Phone", "Phone number", "Mobile Number"),
* but you want to use a single filter "Phone number" to filter by these three fields in the Member Directory.
*
* Note: This example works if the setting "Enable custom table for usermeta" is turned off.
* See the gist https://gist.github.com/denisbaranov/dd8e7c0845af35eeba2bdd08f5f72a76 otherwise.
*
@denisbaranov
denisbaranov / Restore capabilities 'edit_user' and 'delete_user'.php
Created November 18, 2020 14:00
This code snippet restores capabilities 'edit_user' and 'delete_user' if they were blocked by a third-party plugin.
<?php
/**
* This code snippet restores capabilities 'edit_user' and 'delete_user' if they were blocked by a third-party plugin.
*
* You can add this code to the end of the file functions.php in the active theme (child theme) directory.
*
* Ultimate Member documentation: https://docs.ultimatemember.com/
* Ultimate Member support (for customers): https://ultimatemember.com/support/ticket/
*
@denisbaranov
denisbaranov / Custom field that extends the 'checkbox' field type.php
Created June 25, 2020 11:42
This example shows how to add custom predefined field that extends the 'checkbox' field type in Ultimate Member
<?php
/**
* This example shows how to add custom predefined field that extends the 'checkbox' field type in Ultimate Member
* You can add custom code to the end of the file functions.php in the active theme directory.
* Important! You have to change variables: $type, $title, $options
*
* @author Ultimate Member support <support@ultimatemember.com>
* @package Ultimate Member
* @since 2020-06-25
@denisbaranov
denisbaranov / Add several tabs to the profile.php
Last active December 13, 2020 12:59
This example shows how to add several tabs with custom shortcodes into the Profile page of the Ultimate Member.
<?php
/**
* This example shows how to add several tabs with custom shortcodes into the Profile page of the Ultimate Member.
* You can add custom code to the end of the file functions.php in the active theme directory.
* Important! Each tab must have a unique key.
*
* Ultimate Member documentation: https://docs.ultimatemember.com/
* Ultimate Member support (for customers): https://ultimatemember.com/support/ticket/
*/
@denisbaranov
denisbaranov / Validate the email address by domain on registration.php
Last active December 7, 2023 12:19
The following code requires @gmail.com as an email domain for user registrations. You can change @gmail.com to any provider you want. The code below requires a user email to be collected during registration.
<?php
/**
* This example shows how to validate the email address by domain on registration.
* The code below requires a user email to be collected during registration.
*
* Change the array $allowed_email_domains - add or remove what you need.
* Add this code snippet to the end of the file functions.php in the active theme directory.
*
* Ultimate Member documentation: https://docs.ultimatemember.com/
@denisbaranov
denisbaranov / Display fallback value '--' if the field value is empty.php
Last active December 7, 2020 11:21
​Empty fields are hidden on profile form "view" mode. It may look weird. You may use the code snippet below to display fallback value "--" for the empty fields. It works only for the "view" mode. Just add this code snippet to the functions.php file in the active theme (child theme) directory.
<?php
/**
* Displays fallback value if the field value is empty. For the "view" mode only.
* @param string $value
* @param string $default
* @param string $key
* @param string $type
* @param array $data
* @return string