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 / gist:d13302363caa36f2ae8a9281208d5b12
Last active February 14, 2023 14:37 — forked from ultimatemember/gist:5f725bff6bcf79d2988e
Ultimate Member 2.0 - Real-time notification - Add custom notification type
/*
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
*/
@champsupertramp
champsupertramp / Ultimate Member - Imports files and images( except cover and profile photo )
Last active February 5, 2023 07:10
Ultimate Member - Imports files and images( except cover and profile photo )
<?php
/**
* Imports files and images( except cover and profile photo )
* @since UM 2.0
*
* Sample Usage:
* - Fields should be created first in the UM Form Builder.
* - Files should be added to /wp-content/uploads/ultimatemember/<user_id>/ before running the import function.
*
* add_action('init', function(){
@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 - Display Mp3 player in Member Directory Profile Cards
Created January 21, 2022 11:16
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 / profile-tab.php
Last active November 24, 2022 00:46
Ultimate Member - Custom Profile template without headers
<?php /* Template: Profile Tab */ ?>
<div class="um <?php echo $this->get_class( $mode ); ?> um-<?php echo $form_id; ?>">
<div class="um-form">
<?php
$edit = ( isset( $_GET['um_action'] ) && $_GET['um_action'] == 'edit' );
if ( $edit && ! isset( UM()->user()->cannot_edit ) ) {
echo '<form method="post" action="">';
}
@champsupertramp
champsupertramp / Ultimate Member - Hide profile tabs from other user roles
Created May 11, 2016 10:08
Ultimate Member - Hide profile tabs from other user roles
<?php
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$user_id = um_get_requested_user();
// Show to profile owners only
if ( is_user_logged_in() && get_current_user_id() == $user_id ) {
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
<?php
/**
* @um_user_after_updating_profile
*/
function doggycom_redirect_after_updating_profile( $to_update ){
exit( wp_redirect( remove_query_arg( array('profiletab','um_action') ) ) );
}
add_action('um_user_after_updating_profile','doggycom_redirect_after_updating_profile',10,1);
?>