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 - 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 2.0 - Add Profile Photo in Register Form
Created Jun 2, 2019
Ultimate Member 2.0 - Add Profile Photo in Register Form
View Ultimate Member 2.0 - Add Profile Photo in Register Form
/**
* Add new predefined field "Profile Photo" in UM Form Builder.
*/
add_filter("um_predefined_fields_hook","um_predefined_fields_hook_profile_photo", 99999, 1 );
function um_predefined_fields_hook_profile_photo( $arr ){
$arr['profile_photo'] = array(
'title' => __('Profile Photo','ultimate-member'),
'metakey' => 'profile_photo',
@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;
});
@champsupertramp
champsupertramp / gist:d13302363caa36f2ae8a9281208d5b12
Last active Jan 11, 2022 — forked from ultimatemember/gist:5f725bff6bcf79d2988e
Ultimate Member 2.0 - Real-time notification - Add custom notification type
View gist:d13302363caa36f2ae8a9281208d5b12
/*
This code sample shows you how to use the API to create
and add custom notifications (for real-time notifications)
plugin.
STEP 1: You need to extend the filter: um_notifications_core_log_types with your
new notification type as follows for example
*/
View Ultimate Member - Change date format in front-end
<?php
/**
* Change Date format in front-end
*/
add_filter('um_profile_field_filter_hook__date','my_custom_sanitize_fields', 9999, 2 );
function my_custom_sanitize_fields( $value, $data ){
global $ultimatemember;
if( $data['metakey'] == 'date-pickah' ){
$value = $ultimatemember->datetime->format( $value, "d M Y");
@champsupertramp
champsupertramp / Ultimate Member Cron - Delete users awaiting email confirmation after 5 days without getting confirmed
Last active Dec 15, 2021
Ultimate Member Cron - Delete users awaiting email confirmation after 5 days without getting confirmed
View Ultimate Member Cron - Delete users awaiting email confirmation after 5 days without getting confirmed
/**
* More Ultimate Member tutorials at www.champ.ninja
*/
add_action( 'um_cron_delete_users_cron', 'um_delete_users_awaiting_email' );
function um_delete_users_awaiting_email(){
$args = array(
'fields' => 'ID',
'number' => -1,
'date_query' => array(
array( 'after' => '5 days ago midnight', 'inclusive' => true ),
@champsupertramp
champsupertramp / Ultimate Member - change display name with custom name per user role
Created Sep 1, 2016
Ultimate Member - change display name with custom name per user role
View Ultimate Member - change display name with custom name per user role
<?php
// Requires Ultimate Member v1.3.68+
// Change Displayname for Business category profiles
add_filter("um_user_display_name_filter","um_custom_businessname", 10, 2);
function um_custom_businessname( $name, $profile_id ){
um_fetch_user( $profile_id );
if( um_user('role') == 'business' ){
$name = um_user("first_name");
}
@champsupertramp
champsupertramp / Ultimate Member - adding custom fields in account page and tab
Last active Nov 15, 2021
Ultimate Member - adding custom fields in account page and tab
View Ultimate Member - adding custom fields in account page and tab
<?php
/* Add fields to account page */
add_action('um_after_account_general', 'showExtraFields', 100);
function showExtraFields()
{
$custom_fields = [
"alternate_email" => "Permanent E-mail Address",
"major" => "Major",
"minor" => "Minor",
"gpa" => "GPA",
@champsupertramp
champsupertramp / Ultimate Member - Assign specific default Profile Photo to a user role
Created Nov 11, 2021
Ultimate Member - Assign specific default Profile Photo to a user role
View Ultimate Member - Assign specific default Profile Photo to a user role
add_filter("um_user_avatar_url_filter",function( $url, $user_id, $data ){
um_fetch_user( $user_id );
$role = um_user("role");
if( strpos( $url ,"gravatar") > -1 || strpos( $url ,"profile_photo") < -1 ){
if( $role == 'subscriber' ){
return "https://via.placeholder.com/150/0000FF/FFFFFF?text=Subscriber";
}else if( $role == 'administrator' ){
return "https://via.placeholder.com/150/FF0000/FFFFFF?text=Administrator";
}else if( $role == 'bbp_spectator' ){
View Ultimate Member - Get user avatar uri
<?php
/***
*** @Get user avatar uri
***/
// Call ultimatemember global variable
global $ultimatemember;
$user_id = 1;
// Set user ID