Skip to content

Instantly share code, notes, and snippets.

Avatar
🏕️
Working from home

Champ Camba champsupertramp

🏕️
Working from home
View GitHub Profile
@champsupertramp
champsupertramp / Ultimate Member - Reorder languages filter in Member Directory
Created Jan 17, 2023
Ultimate Member - Reorder languages filter in Member Directory
View 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 Jan 2, 2023
Ultimate Member - Support WebP in the Image Uploader
View 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 Dec 19, 2022
Ultimate Member - Restrict Login form for specific role
View 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 Jun 15, 2022
Ultimate Member - Upcoming Birthday future age as tag line in the Member Directory
View 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;
@champsupertramp
champsupertramp / gist:cf6e0bfbaa2691eabda172d7d67a6ff7
Created Jun 15, 2022
Ultimate Member - Display Profiles with Upcoming Birthdays in the Member Directory
View gist:cf6e0bfbaa2691eabda172d7d67a6ff7
add_action('um_user_before_query','um_061522_show_upcoming_birthdays', 10, 2);
function um_061522_show_upcoming_birthdays( $query_args, $obj ){
$directory_id = $obj->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
if( 325 !== $directory_id ) return $query_args;
add_action( 'pre_user_query', function( $uqi ) {
global $wpdb;
@champsupertramp
champsupertramp / gist:2f68b8cf74f5c83244ab3d2e1184c6f9
Created Jun 15, 2022
Ultimate Member - Display Profiles with Today's Birthdays in the Member Directory
View gist:2f68b8cf74f5c83244ab3d2e1184c6f9
add_filter("um_prepare_user_query_args","um_061522_show_todays_birthdays", 10, 2 );
function um_061522_show_todays_birthdays( $query_args, $directory_data ){
$directory_id = $directory_data['form_id'];
if( 320 !== $directory_id ) return $query_args;
$query_args['meta_query'][ ] = array(
'key' => 'birth_date',
'value' => date("/m/d"),
@champsupertramp
champsupertramp / Ultimate Member - Social Login : Sync Square Facebook Avatar
Created Mar 30, 2022
Ultimate Member - Social Login : Sync Square Facebook Avatar
View Ultimate Member - Social Login : Sync Square Facebook Avatar
/**
* Link account to user
*
* @param string $provider
* @param object $getUserProfile
* @param string $returnUrl
* @param boolean $has_linked_account
*
* @since 2.2
@champsupertramp
champsupertramp / Ultimate Member - Make mobile number as username
Created Mar 21, 2022
Ultimate Member - Make mobile number as username
View Ultimate Member - Make mobile number as username
add_action("um_submit_form_register","um_090321_mobile_number_validation");
function um_090321_mobile_number_validation( $post_form ){
if( isset( $post_form['mobile_number'] ) && ! empty( $post_form['mobile_number'] ) ){
global $wpdb;
$wpdb->get_results( $wpdb->prepare("SELECT * FROM {$wpdb->usermeta} WHERE meta_key = 'mobile_number' AND meta_value = %s", $post_form['mobile_number'] ) );
if( $wpdb->num_rows > 0 ) {
UM()->form()->add_error('mobile_number', __( 'Mobile Number already registered', 'ultimate-member' ) );
}
@champsupertramp
champsupertramp / Ultimate Member - Display Mp3 player in Member Directory Profile Cards
Created Jan 21, 2022
Ultimate Member - Display Mp3 player in Member Directory Profile Cards
View Ultimate Member - Display Mp3 player in Member Directory Profile Cards
add_filter("um_ajax_get_members_data","um_012122_display_audio_member_directory_data", 10, 3 );
function um_012122_display_audio_member_directory_data( $data_array, $user_id, $directory_data ){
if( um_profile( 'mp3' ) ){
$mp3_url = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . um_profile( 'mp3' );
$data_array['audio_embed'] = "
<audio controls style='width: 90%;margin:auto;'>
<source src='{$mp3_url}' type='audio/mpeg'>
Your browser does not support the audio element.
</audio>";
@champsupertramp
champsupertramp / Ultimate Member - Make UM Files Field including cover and profile photos syncronized
Last active Jan 13, 2022
Ultimate Member - Make UM Files Field including cover and profile photos syncronized
View Ultimate Member - Make UM Files Field including cover and profile photos syncronized
add_filter("upload_dir", function( $upload ){
if( ( isset( $_REQUEST['action'] ) && ( "um_resize_image" == $_REQUEST['action'] || "um_imageupload" == $_REQUEST['action'] ) ) || isset( $_REQUEST['um_action'] ) ){
$upload['basedir'] = str_replace( "/sites/2", "", $upload['basedir'] );
$upload['baseurl'] = str_replace( "/sites/2", "", $upload['baseurl'] );
}
return $upload;
});