Skip to content

Instantly share code, notes, and snippets.

Avatar
🏕️
Working from home

Champ Camba champsupertramp

🏕️
Working from home
View GitHub Profile
@champsupertramp
champsupertramp / currency_symbols.php
Last active Aug 31, 2015 — forked from gibbs/currency_symbols.php
An array of currency symbols as HTML entities
View currency_symbols.php
<?php
$currency_symbols = array(
'AED' => '&#1583;.&#1573;', // ?
'AFN' => '&#65;&#102;',
'ALL' => '&#76;&#101;&#107;',
'AMD' => '',
'ANG' => '&#402;',
'AOA' => '&#75;&#122;', // ?
'ARS' => '&#36;',
'AUD' => '&#36;',
@champsupertramp
champsupertramp / gist:e412635fee8701c759f7
Created Nov 9, 2015
Ultimate Member: Social Login – Redirecting to homepage, and not logging in or registering or CSRF tokens/state mismatch
View gist:e412635fee8701c759f7
/**
*** If you're using a custom WordPress theme, one of the possible causes of the issue is ' Post Relational Links ' added in the Header
*** ( https://developer.wordpress.org/reference/functions/adjacent_posts_rel_link/ )
** This feature loads pages in the background process and it causes the register page to load multiple times.
** It reloads the Social Tokens again and causes mismatch session keys during authentication
**
**/
remove_action('wp_head', 'start_post_rel_link', 10, 0 );
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
View Ultimate Member - Fix broken images in wall posts after updating profile
/**
* @detach action 'um_remove_unused_uploads'
*/
function detach_um_remove_unused_uploads( $arg ){
remove_action('um_after_user_upload','um_remove_unused_uploads', 10 );
}
add_action('um_after_user_updated','detach_um_remove_unused_uploads',10,1);
@champsupertramp
champsupertramp / Ultimate Member - Submit Search form on Enter
Created Jan 6, 2016
Ultimate Member - Submit Search form on Enter
View Ultimate Member - Submit Search form on Enter
jQuery(function(){
jQuery(".um-search form *").keypress(function(e){
if (e.which == 13) {
jQuery('.um-search form').submit();
return false;
}
});
});
@champsupertramp
champsupertramp / Ultimate Member: shortcode to show content for specific role
Last active Feb 26, 2016
Ultimate Member: shortcode to show content for specific role
View Ultimate Member: shortcode to show content for specific role
/**
* Usage:
* [um_show_content roles='member'] <!-- insert content here --> [/um_show_content]
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
**/
if( ! function_exists("um_shortcode_show_content_for_role") ){
function um_shortcode_show_content_for_role( $atts = array() , $content = '' ) {
$a = shortcode_atts( array(
'roles' => 'member',
), $atts );
@champsupertramp
champsupertramp / Ultimate Member - Display name, first and last name cases
Created Aug 18, 2016
Ultimate Member - Display name, first and last name cases
View Ultimate Member - Display name, first and last name cases
// Requires Ultimate Member v 1.3.69 above.
add_filter("um_user_first_name_case","um_custom_name_case");
add_filter("um_user_last_name_case","um_custom_name_case");
function um_custom_name_case( $string )
{
$word_splitters = array(' ', '-', "O'", "L'", "D'", 'St.', 'Mc', 'Mac');
$lowercase_exceptions = array('the', 'van', 'den', 'von', 'und', 'der', 'de', 'di', 'da', 'of', 'and', "l'", "d'");
$uppercase_exceptions = array('III', 'IV', 'VI', 'VII', 'VIII', 'IX');
@champsupertramp
champsupertramp / Ultimate Member - Calculate two profile fields
Created Aug 18, 2016
Ultimate Member - Calculate two profile fields
View Ultimate Member - Calculate two profile fields
<?php
// Profile View
add_filter("um_profile_field_filter_hook__myMetaKeyC","um_profile_field_filter_hook__myMetaKeyC");
function um_profile_field_filter_hook__myMetaKeyC( $value, $data ){
$a = um_user("myMetaKeyA");
$b = um_user("myMetaKeyB");
$value = intval( $a ) + intval( $b );
return $value;
@champsupertramp
champsupertramp / Ultimate Member - Custom Email Template
Last active Dec 15, 2016
Ultimate Member - Custom Email Template
View Ultimate Member - Custom Email Template
<?php
/***
*** Custom Email Template
****/
function um_custom_email_template(){
global $ultimatemember, $user_ID;
um_fetch_user( $user_ID );
@champsupertramp
champsupertramp / Ultimate Member - Hides current user from search query in member directory
Created Sep 18, 2016
Ultimate Member - Hides current user from search query in member directory
View 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;
View Ultimate Member - Sanitize fields
<?php
/**
* Custom sanitization of fields
*/
add_filter('um_profile_field_filter_hook__','my_custom_sanitize_fields', 99, 2 );
function my_custom_sanitize_fields( $value, $data ){
// Add tags to mail value
if ( !is_array( $value ) ) {