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 Groups - Notify a user when someone created a group
Created May 18, 2020 13:30
Ultimate Member Groups - Notify a user when someone created a group
<?php
/**
* Author: Champ
* Site: www.champ.ninja
*/
/**
* 1. Set the recipient email with the variable $member_address
* 2. Ensure that this new email template is turned on in WP Admin > Ultimate Member > Settings > Emails
*/
@champsupertramp
champsupertramp / Ultimate Member - Redirect user to a custom page when viewing a profile that has been deleted
Created May 18, 2020 13:10
Ultimate Member - Redirect user to a custom page when viewing a profile that has been deleted
<?php
/**
* Subscribe to my newsletter: www.champ.ninja
*/
add_filter("um_locate_user_profile_not_loggedin__redirect",""um_custom_deleted_profile_redirect", 99 );
function um_custom_deleted_profile_redirect( $url ){
$url = '/my-404-page/';
return $url;
}
?>
@champsupertramp
champsupertramp / Ultimate Member - Add custom menu shortcode-short tags
Created May 17, 2020 07:45
Ultimate Member - Add custom menu shortcode/short tags
<?php
/**
* Subscribe to my newsletter: www.champ.ninja
*/
​add_filter("um_allowed_user_tags_patterns","um_custom_tags_patterns");
​function um_custom_tags_patterns( $patterns ){
​ $patterns = "{user_avatar_large}";
​ return $patterns;
​}
@champsupertramp
champsupertramp / Ultimate Member - Make Thumbnail image show in Social Media sites posts
Last active April 27, 2020 09:06
Ultimate Member - Make Thumbnail image show in Social Media sites posts
function um_custom_profile_dynamic_meta_desc() {
global $post;
$image_id = get_post_thumbnail_id( $post->ID );
$image_url = wp_get_attachment_image_src( $image_id, 'thumbnail', true ); ?>
?>
<meta property="og:image" content="<?php echo esc_url( $image_url ); ?>"/>
<?php
@champsupertramp
champsupertramp / Ultimate Member - Add error message above profile or register form for long forms
Created March 16, 2020 15:34
Ultimate Member - Add error message above profile/register form for long forms
<?php
add_action("um_before_form","um_custom_error_message_before_form", 9, 1 );
function um_custom_error_message_before_form( $args ){
if( $args['form_id'] != 123 ) return; // apply to form ID 123
if ( UM()->form()->count_errors() > 0 ) {
_e("There are field errors below","ultimate-member");
}
@champsupertramp
champsupertramp / Ultimate Member 2.1 - Add search & reset buttons in member directory
Last active April 28, 2024 02:34
Ultimate Member 2.1 - Add search & reset buttons in member directory
<?php
add_action("um_members_directory_head","um_custom_members_directory_head",10, 1 );
function um_custom_members_directory_head( $args )
{
?>
<div class="um-search-submit" style="margin:auto;width:50%;">
<div style="width: 40%;float:left;margin:10px;text-align:center;">
<a href="#" class="um-button um-do-search" ><?php _e("Search","ultimate-member"); ?></a>
</div>
@champsupertramp
champsupertramp / Ultimate Member 2.0 - Profile Photo custom Width and Height
Created November 26, 2019 14:31
Ultimate Member 2.0 - Profile Photo custom Width and Height
<?php
add_filter("um_upload_image_process__profile_photo","um_custom_profile_photo_size", 1, 7 );
function um_custom_profile_photo_size( $response, $image_path, $src, $key, $user_id, $coord, $crop ){
$quality = UM()->options()->get( 'image_compression' );
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor
$temp_image_path = $image_path;
//refresh image_path to make temporary image permanently after upload, generates file name e.g. profile_photo-custom.jpeg
@champsupertramp
champsupertramp / gist:59830f60a167f5523f00c99a223b13bf
Last active November 22, 2019 11:35
Ultimate Member - Redirect Users to custom page when account is still not verified and completed the profile
<?php
// Current logged in user
$user_id = get_current_user_id();
if( class_exists("UM_Verified_Users_API") && class_exists("UM_Profile_Completeness_API") ){ // check if extensions exist and active
if( is_user_logged_in() && ! is_page("custom-page-slug") ){ // If user is logged in / don't redirect when in the dashboard or custom page.
$get_progress = UM()->Profile_Completeness_API()->get_progress( $user_id );
if ( $get_progress['progress'] == 100 ) { // Check if progress is 100
@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 - Real-time notifications - Shortcode for Menus
Created July 3, 2019 15:13
Ultimate Member - Real-time notifications - Shortcode for Menus
<?php
/**
* Add notification count tag value
* {notification_count}
*/
add_filter( ‘um_profile_tag_hook__notification_count’,‘um_custom_notification_count’, 10, 2 );
function um_custom_notification_count( $value, $user_id ){
$count = UM()->Notifications_API()->api()->get_notifications( 0, 'unread', true );
return '<span class="um-notification-unreaditems count-'. $count . '">' . ( ( $count > 10 ) ? 10 . '+' : $count ) . '</span>';