Skip to content

Instantly share code, notes, and snippets.

View champsupertramp's full-sized avatar
🏕️
Working from home

Champ Camba champsupertramp

🏕️
Working from home
View GitHub Profile
@champsupertramp
champsupertramp / Ultimate Member - Increase Pagination Range in Member Directory
Created October 11, 2023 12:15
Ultimate Member - Increase Pagination Range in Member Directory
<?php
add_filter( 'um_ajax_get_members_response', function( $data ) {
$pagination_range = 6;
$max_value = max( $data['pagination']['pages_to_show'] ) + $pagination_range;
$min_value = min( $data['pagination']['pages_to_show'] ) - $pagination_range;
if( $max_value >= $data['pagination']['total_pages'] ) {
$max_value = $data['pagination']['total_pages'];
}
@champsupertramp
champsupertramp / Ultimate Member - Profile URL compatibility with Social Sharing plugins, Sociaholic
Created September 13, 2023 08:57
Ultimate Member - Profile URL compatibility with Social Sharing plugins, Sociaholic
function um_091323_profile_page_link( $permalink, $post_id, $leavename ){
if ( ! class_exists( 'UM' ) || did_action( 'um_profile_header' ) || ! doing_action( 'wp_head' ) ) {
return $permalink;
}
if( $post_id === UM()->config()->permalinks['user'] ) {
$profile_page_slug = get_post_field( 'post_name', UM()->config()->permalinks['user'] );
$arr = explode('/', home_url( $profile_page_slug . '/' . get_query_var( 'um_user' ) ) );
$permalink = implode('/', array_unique( $arr ) );
}
@champsupertramp
champsupertramp / Ultimate Member - User Shortcode - conditional displaying of meta value
Created September 12, 2023 08:32
Ultimate Member - User Shortcode - conditional displaying of meta value
add_filter('um_user_shortcode_filter__country', 'um_091223_user_shortcode_country' );
function um_091223_user_shortcode_country( $value ) {
$current_logged_user_id = get_current_user_id();
um_fetch_user( $current_logged_user_id );
if( um_user('country') ) {
return $value; // returns the country of the current viewing profile when the current logged-in user's country is not empty
}
@champsupertramp
champsupertramp / Ultimate Member - Social Login - change button labels in Register page
Created September 6, 2023 12:31
Ultimate Member - Social Login - change button labels in Register page
add_action( 'template_redirect', 'um_sso_090623_customization_init' );
function um_sso_090623_customization_init() {
if ( ! class_exists( 'UM' ) ) {
return;
}
if ( um_is_core_page( 'register' ) ) {
add_filter( 'um_social_login_networks', function( $providers ) {
$providers['facebook']['button'] = __( 'Continue with Facebook', 'um-social-login' );
$providers['google']['button'] = __( 'Sign up with Google', 'um-social-login' );
@champsupertramp
champsupertramp / Ultimate Member Social Login - LinkedIn API backward compatibility
Last active August 30, 2023 12:00
Ultimate Member Social Login - LinkedIn API backward compatibility
<?php
add_filter( 'um_social_login_linkedin__config', 'um_social_login_linkedin_backward_compatibility__config' );
function um_social_login_linkedin_backward_compatibility__config( $config ) {
$config['provider'] = 'LinkedIn';
$config['scope'] = array( 'r_liteprofile', 'r_emailaddress' ); // Add `w_member_social` in the array if you have the permission to use it.
return $config;
}
@champsupertramp
champsupertramp / Ultimate Member - Exclude specific emails from blocked email domains
Last active February 1, 2023 13:59
Ultimate Member - Exclude specific emails from blocked email domains
function um_020123_submit_form_errors_hook__exclude_blockedemails( $args ) {
$emails = UM()->options()->get( 'blocked_emails' );
if ( ! $emails ) {
return;
}
$arr_excluded_emails = array(
"test1@gmail.com",
"test2@gmail.com",
);
@champsupertramp
champsupertramp / Ultimate Member - Reorder languages filter in Member Directory
Created January 17, 2023 13:08
Ultimate Member - Reorder languages filter in Member Directory
add_filter("um_member_directory_filter_select_options_sorted","um_011723_sort_languages",10,2);
function um_011723_sort_languages( $options, $atts ){
if( "languages" == $atts['metakey'] ){
$key = 'en';
$value = $options[$key];
unset($options[$key]);
array_unshift($options, $value);
@champsupertramp
champsupertramp / Ultimate Member - Support WebP in the Image Uploader
Last active January 2, 2023 14:43
Ultimate Member - Support WebP in the Image Uploader
<?php
// Cover & Profile Photo
add_filter("um_get_field__cover_photo","um_010223_allowed_webp_image_type", 10, 1 );
add_filter("um_get_field__profile_photo","um_010223_allowed_webp_image_type", 10, 1 );
function um_010223_allowed_webp_image_type( $data ){
$arr = explode( ",", $data['allowed_types'] );
$arr[ ] = "webp";
$data['allowed_types'] = implode(",", $arr);
@champsupertramp
champsupertramp / Ultimate Member - Restrict Login form for specific role
Created December 19, 2022 11:26
Ultimate Member - Restrict Login form for specific role
add_action( 'um_submit_form_errors_hook_login', 'um_071621_login_for_specific_role', 10 );
function um_071621_login_for_specific_role( $args ){
if ( isset( $args['username'] ) && $args['username'] == '' ) {
return;
}
if ( isset( $args['user_login'] ) && $args['user_login'] == '' ) {
return;
}
@champsupertramp
champsupertramp / Ultimate Member - Upcoming Birthday future age as tag line in the Member Directory
Created June 15, 2022 10:20
Ultimate Member - Upcoming Birthday future age as tag line in the Member Directory
add_filter("um_ajax_get_members_data","um_061522_future_age_birthdays", 10, 3 );
function um_061522_future_age_birthdays( $data_array, $user_id, $directory_data ){
$directory_id = $directory_data['form_id'];
if( 325 !== $directory_id ) return $data_array;
um_fetch_user( $user_id );
$hours_in_day = 24;