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 / 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 / Site language custom field
Created May 12, 2021 06:27
Site language custom field
function um_051221_site_locale(){
$arr = [
"en" => "English (United States)",
'cs_CZ' => "Čeština",
'es_AR' => "Español de Argentina",
];
return $arr;
}
@champsupertramp
champsupertramp / Ultimate Member - Account form Image upload function
Last active October 2, 2022 15:13
Ultimate Member - Account form Image upload function
/**
* Tutorial: https://www.champ.ninja/2020/05/add-a-custom-account-tab-with-profile-form-fields/
*/
add_filter("um_user_pre_updating_files_array", function($files ){
$user_id = get_current_user_id();
if( empty( $user_id ) ) return $files;
$new_files = array();
@champsupertramp
champsupertramp / Ultimate Member - show tabs at the last tab
Created March 23, 2021 10:02
Ultimate Member - show tabs at the last tab
add_filter("um_user_profile_tabs", function( $tabs ){
$arr_followers = $tabs['followers'];
$arr_following = $tabs['following'];
unset( $tabs['followers'] );
unset( $tabs['following'] );
$tabs['followers'] = $arr_followers;
@champsupertramp
champsupertramp / Ultimate Member Profile Tabs with Contact Form 7
Last active February 19, 2021 05:04
Ultimate Member Profile Tabs with Contact Form 7
add_filter( 'wpcf7_mail_components', 'um_020821_change_email_to_profile_owner_email', 10, 3 );
function um_020821_change_email_to_profile_owner_email( $args, $contact_form, $class){
if ( class_exists( '\WPCF7_Submission' ) ) {
$submission = \WPCF7_Submission::get_instance();
$page = $submission->get_meta( 'container_post_id' );
if ( intval( UM()->options()->get( 'core_user' ) ) == intval( $page ) ) {
if ( ! empty( $_REQUEST['_wpcf7_um_profile_id'] ) ) {
$user = get_user_by( 'ID', absint( $_REQUEST['_wpcf7_um_profile_id'] ) );
if ( ! is_wp_error( $user ) && isset( $user->user_email ) && is_email( $user->user_email ) ) {
@champsupertramp
champsupertramp / Ultimate Member - Password Reset Link in Welcome Email
Last active January 17, 2024 08:07
Ultimate Member - Password Reset Link in Welcome Email
@champsupertramp
champsupertramp / Ultimate Member - Shortcode for Login URL with redirect in Global Access Message
Last active August 18, 2022 07:40
Ultimate Member - Shortcode for Login URL with redirect in Global Access Message
/**
* Add a shortcode to display the Login URL with redirection URL
* e.g. http://www.yoursite.com/login/?redirect_to=http://www.yoursite.com/content-restriction/
* www.champ.ninja
*/
add_shortcode("um_login_redirect","um_login_redirect",10, 2 );
function um_login_redirect( $atts, $content ){
global $wp;
@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 - Enable username input in Social Profile URLs Field
Last active October 22, 2020 08:24
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 August 18, 2020 13:47
Ultimate Member - Open GDPR terms and condition link to a new tab
<?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">