Skip to content

Instantly share code, notes, and snippets.

View cryptexvinci's full-sized avatar
🏆
Focusing

Towhid cryptexvinci

🏆
Focusing
  • Ultimate Member Group Ltd
  • Bangladesh
View GitHub Profile
@cryptexvinci
cryptexvinci / um-wp-rocket.php
Last active August 12, 2025 08:17
Exclude Ultimate Member pages from WP Rocket cache
<?php
/**
* Exclude Ultimate Member pages from WP Rocket cache
* Add this to your theme's functions.php file or create a custom plugin
*/
/**
* To disable WP Rocket cache for Ultimate Member pages.
*
* @return void
@cryptexvinci
cryptexvinci / show-unapproved-member.php
Created August 8, 2025 07:17
Show unapproved members in the member directory for all User Roles
<?php
/**
* Enable viewing of unapproved members in the member directory
*
* Hooks into the member directory query to temporarily allow all users
* to view unapproved members by modifying user permissions.
*/
function um_enable_view_unapproved_members() {
add_filter( 'um_user_permissions_filter', 'um_allow_edit_everyone_permission' );
@cryptexvinci
cryptexvinci / friends.php
Last active August 8, 2025 07:23
Ultimate Member - Friends Extensions - Automatically add specific users as friends when a new user registers
<?php
/**
* Automatically add specific users as friends when a new user registers
*
* This function hooks into the Ultimate Member user registration process
* and automatically creates friend connections between new users and
* a predefined list of existing members.
*/
// Hook into the UM user registration process
@cryptexvinci
cryptexvinci / um-group.php
Created January 6, 2024 16:56
Ultimate Member - Adds a user to a specified group
<?php
/*
* Adds a user to a specified group with specific details, such as the group ID, user ID,
* when a user registers on a website using the Ultimate Member plugin.
*/
add_action( 'um_registration_set_extra_data', 'my_registration_set_extra_data', 10, 2 );
function my_registration_set_extra_data( $user_id, $args ) {
@cryptexvinci
cryptexvinci / exclude-search.php
Last active August 8, 2025 07:40
Ultimate Member - Exclude a specific field from the search results in the Ultimate Member directory
<?php
/**
* Exclude a specific field from the search results in the Ultimate Member directory
*
* This code prevents the 'referred_by' field from being included when users
* search through the members directory, while still allowing other fields
* to be searched normally.
*/
/**
@cryptexvinci
cryptexvinci / update-existing-pm.php
Created April 5, 2023 02:47
Update private messaging option for all existing users.
<?php
/**
* Update private messaging option for all existing users.
* @return void
*/
function um_update_existing_users_pm_option() {
// Get all existing users.
$users = get_users();
// Loop through each user and update their private messaging option to 'friends'.
@cryptexvinci
cryptexvinci / private-message-default.php
Created April 5, 2023 02:44
Set the default value for private messaging option on user register or add.
<?php
/**
* Set the default value for private messaging option on user register or add.
* @param int $user_id The ID of the newly registered user.
* @return void
*/
function um_change_who_can_pm_default( $user_id ) {
// Set the default value for private messaging option to 'friends' for the new user.
update_user_meta( $user_id, '_pm_who_can', 'friends' );
@cryptexvinci
cryptexvinci / gist:a159a8f394e797e0ee16961c4e9e83b2
Last active March 22, 2023 04:19
Get Ultimate member Search Term or keyword
<?php
/**
* Gets the search term from the member directory search query.
*
* @return void
*/
function um_member_directory_search_term() {
// Only execute on the members page.
if ( ! um_is_core_page( 'members' ) ) {
return;
@cryptexvinci
cryptexvinci / privacy.php
Created February 28, 2023 05:32
Set Profile Privacy = "who can see profile" to Friends only
<?php
/* Set default values for privacy in new accounts
*
* Set Profile Privacy = "who can see profile" to Friends only
*/
add_action("um_registration_complete","custom_um_user_registration_complete", 1);
function custom_um_user_registration_complete( $user_id ){
update_user_meta( $user_id, "profile_privacy", "Friends only");
}
@cryptexvinci
cryptexvinci / um-custom-checkbox-output.php
Created August 3, 2022 06:23
Ultimate Member - Display checkbox output in columns
<?php
add_filter( "um_view_field_value_checkbox", "my_um_view_field_value_checkbox", 10, 2 );
function my_um_view_field_value_checkbox( $html, $data ) {
if ( $data['metakey'] != 'your_checkbox_meta_key' ) {
return $html;
}