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 - 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 - User meta shortcodes
Last active August 31, 2023 09:06
Ultimate Member - User meta shortcodes
/**
* Returns a user meta value
* Usage [um_user user_id="" meta_key="" ] // leave user_id empty if you want to retrive the current user's meta value.
* meta_key is the field name that you've set in the UM form builder
* You can modify the return meta_value with filter hook 'um_user_shortcode_filter__{$meta_key}'
*/
function um_user_shortcode( $atts ) {
$atts = extract( shortcode_atts( array(
'user_id' => get_current_user_id(),
'meta_key' => '',
@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 / Display Specific Profile with a Shortcode on a Page
Created August 23, 2021 07:43
Display Specific Profile with a Shortcode on a Page
/**
* Sample usage: [um_embed_profile user_id="123" form_id="3"]
*/
add_shortcode("um_embed_profile","um_082321_embed_specific_profile");
function um_082321_embed_specific_profile( $atts ){
$atts = shortcode_atts( array(
'user_id' => get_current_user_id(),
'form_id' => 0,
), $atts );
@champsupertramp
champsupertramp / Ultimate Member - Assign specific default Profile Photo to a user role
Created November 11, 2021 07:30
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' ){
@champsupertramp
champsupertramp / Ultimate Member - Hides current user from search query in member directory
Created September 18, 2016 14:43
Ultimate Member - Hides current user from search query in member directory
<?php
/**
* Hides current user from search query in member directory
*/
add_filter('um_prepare_user_query_args', 'um_remove_current_user_from_query', 10, 2);
function um_remove_current_user_from_query( $query_args, $args ){
$query_args['exclude'] = array( get_current_user_id() );
return $query_args;
@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(){