This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'um_submit_form_errors_hook__registration', 'um_custom_validate_username', 99 ); | |
function um_custom_validate_username( $args ) { | |
static $domain = '.in, .ru'; | |
if ( isset( $args['user_email'] ) ) { | |
if ( str_ends_with( $args['user_email'], '.in' ) || str_ends_with( $args['user_email'], '.ru' )) { | |
$message = sprintf( __( 'Cant use email domain %1$s for registration', 'ultimate-member' ), $domain ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Code snippet of Plugin Ultimate Member | |
URL: https://wordpress.org/plugins/ultimate-member/ | |
*/ | |
// Display field data of Ultimate Member | |
// e.g. [um_field_data userid='24'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Display UM Country Column Label | |
function um_add_meta_user_table( $column ) { | |
$column['country'] = 'Country'; | |
return $column; | |
} | |
add_filter( 'manage_users_columns', 'um_add_meta_user_table' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'um_after_member_role_upgrade', 'my_um_after_member_role_upgrade', 10, 3 ); | |
function my_um_after_member_role_upgrade( $hook_roles, $old_roles, $user_id ){ | |
$user = get_userdata( $user_id ); | |
UM()->mail()->send( $user->user_email, 'welcome_email' ); | |
} |
NewerOlder