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-registration-email.php
Created August 3, 2022 05:28
Ultimate Member Registration - List "disallowed" domain extensions such as .ru and .in
<?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 );
@cryptexvinci
cryptexvinci / um-after-post-profile.php
Created March 29, 2022 04:47
display the user profile like at the end of the blog post where I only have to change the user id.
<?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']
@cryptexvinci
cryptexvinci / um_user_column_backend.php
Created January 21, 2022 03:28
Add custom Ultimate member fields Column to Users list table on WordPress
<?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' );
@cryptexvinci
cryptexvinci / mail-role-change.php
Created August 31, 2021 10:27
Ultimate Member - Send Welcome Email after Role Change.
<?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' );
}
@cryptexvinci
cryptexvinci / um-post-tab-cat.php
Created May 25, 2021 02:31
How to let a profile tab display posts published in a certain category by this user?
<?php
add_action('um_profile_menu', 'um_profile_content_posts_custom_cat');
function um_profile_content_posts_custom_cat(){
$active_tab = UM()->profile()->active_tab();
if ($active_tab == 'posts') {
@cryptexvinci
cryptexvinci / um-force-private-profile.php
Last active March 6, 2024 08:37
Make all Ultimate Member User Profiles Private by Default.
<?php
/**
* Ultimate member - Make all UM User Profile Private by Default.
* URL: https://wordpress.org/plugins/ultimate-member/
*/
add_filter( 'get_user_metadata', function( $profile_privacy, $object_id, $meta_key ) {
if( $meta_key === 'profile_privacy' ) {
$profile_privacy = 'Only me';
}
return $profile_privacy;
@cryptexvinci
cryptexvinci / um-email-registration.php
Last active November 21, 2020 03:32
Ultimate Member - Only use a Selected email domain for registration
<?php
/**
* Ultimate member - Restrict registration based on email domain.
* URL: https://wordpress.org/support/topic/email-domain-restriction-at-registration/
*/
add_action( 'um_submit_form_errors_hook__registration', 'um_register_email_provider_restrict', 99 );
function um_register_email_provider_restrict( $args ) {
// List the email providers you want to allow
$allowed_domains = array('@gmail.com', '@hey.com');
@cryptexvinci
cryptexvinci / um-upload.php
Last active November 21, 2020 03:10
Ultimate Member - Get custom field uploaded image url
<?php
/**
* Display custom field image url in Member Directory
* URL: https://wordpress.org/support/topic/get-uloaded-image-url/
*/
add_action( 'um_members_just_after_name', 'custom_function_tester_dir' );
function custom_function_tester_dir(){
// Get the filename
$image_filename = um_user( 'national_id' );
@cryptexvinci
cryptexvinci / um-core-fields.php
Created October 12, 2020 04:42
Change Ultimate Member text/label with the filter hook
<?php
/*
* title & label Gender to Gender Identity
* see: https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-builtin.php#L832
*
* @param 'title', 'metakey', 'type', 'label', 'required', 'public', 'editable', 'options'
*
* @return array
*/
add_filter( 'um_core_fields_hook', 'um_custom_modify_text', 10, 1 );
@cryptexvinci
cryptexvinci / um-user-admin.php
Created September 28, 2020 03:53
Custom Ultimate Member fields in WordPress User Admin Panel
<?php
add_filter( 'manage_users_columns', 'um_custom_add_new_user_column' );
function um_custom_add_new_user_column( $columns ) {
$columns['um_country'] = 'Country';
return $columns;
}
add_filter( 'manage_users_custom_column', 'um_custom_add_new_user_column_content', 10, 3 );