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 - Imports files and images( except cover and profile photo )
Last active Dec 4, 2020
Ultimate Member - Imports files and images( except cover and profile photo )
View 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 - Enable username input in Social Profile URLs Field
Last active Oct 22, 2020
Ultimate Member - Enable username input in Social Profile URLs Field
View Ultimate Member - Enable username input in Social Profile URLs Field
<?php
/**
* @note - Ensure that the Social Profile URLs validation is set to "Alpha-Numeric Value" instead of "Facebook URL" etc.
*/
add_filter( 'um_profile_field_filter_hook__', 'um_custom_social_profile_links', 88, 3 );
function um_custom_social_profile_links( $value, $data, $type ){
if ( ! $value ) {
return '';
}
@champsupertramp
champsupertramp / gdpr-register.php ​
Created Aug 18, 2020
Ultimate Member - Open GDPR terms and condition link to a new tab
View gdpr-register.php ​
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<div class="um-field um-field-type_terms_conditions" data-key="use_terms_conditions_agreement" style="display:block;padding:0;">
<div class="um-field-area">
<?php $confirm = ! empty( $args['use_gdpr_agreement'] ) ? $args['use_gdpr_agreement'] : __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ); ?>
<label class="um-field-checkbox">
@champsupertramp
champsupertramp / um-terms-conditions-public-display.php
Last active Aug 18, 2020
Ultimate Member - Terms & Conditions : Open to a new tab instead of displaying the full content in the form
View um-terms-conditions-public-display.php
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<div class="um-field um-field-type_terms_conditions" data-key="use_terms_conditions_agreement" style="display: block;padding:0px">
<div class="um-field-area">
<div class="um-terms-conditions-content" style="display:none">
<?php if ( ! empty( $args['use_terms_conditions_content_id'] ) ) {
if ( isset( $um_content_query ) ) { ?>
<a href="<?php echo get_the_permalink( $args['use_terms_conditions_content_id'] );?>" target="_blank" class="um-hide-terms">
<?php echo ! empty( $args['use_terms_conditions_toggle_hide'] ) ? $args['use_terms_conditions_toggle_hide'] : __( 'Hide Terms', 'um-terms-conditions' ); ?>
</a>
<?php echo apply_filters( 'um_terms_conditions_tc_page_content', $um_content_query->post_content, $args );
@champsupertramp
champsupertramp / Ultimate Member 2.1.6 - Open files in the current window
Created Aug 11, 2020
Ultimate Member 2.1.6 - Open files in the current window
View Ultimate Member 2.1.6 - Open files in the current window
<?php
/**
* Open files in the current window
* @author www.champ.ninja
*
**/
add_filter("um_profile_field_filter_hook__file","um_custom_profile_field_filter_hook__file", 100);
function um_custom_profile_field_filter_hook__file( $output ){
$output = str_replace("_blank","", $output );
return $output;
@champsupertramp
champsupertramp / Ultimate Member 2.3 - Mass update to add new role to content restrictions in all posts
Created Jul 28, 2020
Ultimate Member 2.3 - Mass update to add new role to content restrictions in all posts
View Ultimate Member 2.3 - Mass update to add new role to content restrictions in all posts
add_action("template_redirect","um_custom_add_new_role_posts_restriction");
function um_custom_add_new_role_posts_restriction(){
$p_query = new WP_Query;
$posts = $p_query->query( array(
'post_type' => 'any',
'posts_per_page' => -1,
'fields' => 'ids'
) );
if ( ! empty( $posts ) ) {
@champsupertramp
champsupertramp / Social Login 2.3 - Enable WeChat authentication
Last active Jul 31, 2020
Social Login 2.3 - Enable WeChat authentication
View Social Login 2.3 - Enable WeChat authentication
add_filter("um_social_login_networks","um_sso_add_wechat_network", 10, 1 );
function um_sso_add_wechat_network( $networks ){
$networks["wechat"] = array(
'name' => __( 'WeChat', 'um-social-login' ),
'button' => __( 'Sign in with WeChat', 'um-social-login' ),
'color' => '#ffffff',
'bg' => '#444444',
'bg_hover' => '#000000',
'icon' => 'um-faicon-weixin',
@champsupertramp
champsupertramp / Ultimate Member - Custom Profile tab with custom link
Created Jun 6, 2020
Ultimate Member - Custom Profile tab with custom link
View Ultimate Member - Custom Profile tab with custom link
@champsupertramp
champsupertramp / profile-tab.php
Last active May 31, 2020
Ultimate Member - Custom Profile template without headers
View profile-tab.php
<?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 - Private Messages - Hide Message button in current viewing profile for Specific User Role
Created May 20, 2020
Ultimate Member - Private Messages - Hide Message button in current viewing profile for Specific User Role
View Ultimate Member - Private Messages - Hide Message button in current viewing profile for Specific User Role
/** More UM tutorial at www.champ.ninja **/
function um_private_message_button_visiblity(){
if ( class_exists( 'UM_Messaging_API' ) && ! um_is_myprofile() ) { // Apply this logic when not in his own profile
$user_id = get_current_user_id();
um_fetch_user( $user_id );
if( um_user("role") == "free-tier-member" ){ // Hide member buttons from Free Tier roles
remove_action( 'um_profile_navbar', array( UM()->Messaging_API()->profile(), 'add_profile_bar' ), 5 );