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-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 );
@cryptexvinci
cryptexvinci / um-old-css.php
Created August 18, 2020 14:56
Remove Ultimate Member um_old_css
<?php
add_action( 'wp_enqueue_scripts', 'um_remove_old_css', UM()->enqueue()->get_priority() + 1 );
if ( ! function_exists( 'um_remove_old_css' ) ) {
function um_remove_old_css() {
wp_dequeue_style( 'um_default_css' );
wp_dequeue_style( 'um_old_css' );
}
}
@cryptexvinci
cryptexvinci / tutor-lms-um-msg.php
Last active October 12, 2020 04:45
Display Ultimate Member Message button in TutorLMS student profile.
<?php
add_action('tutor_student/before/wrap', 'display_tutor_msg' );
function display_tutor_msg(){
$user_name = sanitize_text_field(get_query_var('tutor_student_username'));
$sub_page = sanitize_text_field(get_query_var('profile_sub_page'));
$get_user = tutor_utils()->get_user_by_login($user_name);
$user_id = $get_user->ID;
<?php
add_action( 'init', 'hide_secure_wp_admin' );
function hide_secure_wp_admin() {
if ( is_admin() || $GLOBALS['pagenow'] === 'wp-login.php' ) {
// Non logged in users.
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
wp_redirect( um_get_core_page('login') );
}
}
@cryptexvinci
cryptexvinci / um-member-directory.php
Created May 31, 2020 06:50
Member Directory Javascript
{{{user.data_field}}}
// eg: {{{user.country}}}