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 / currency_symbols.php
Last active August 31, 2015 18:11 — forked from gibbs/currency_symbols.php
An array of currency symbols as HTML entities
<?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 November 9, 2015 07:04
Ultimate Member: Social Login – Redirecting to homepage, and not logging in or registering or CSRF tokens/state mismatch
/**
*** 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);
/**
* @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 January 6, 2016 06:32
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 February 26, 2016 10:37
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 August 18, 2016 08:12
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 August 18, 2016 08:38
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;
<?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 ) ) {
@champsupertramp
champsupertramp / Ultimate Member - Disable nonce in registration form
Created April 19, 2017 11:07
Ultimate Member - Disable nonce in registration form
<?php
add_filter("um_register_allow_nonce_verification","um_custom_disable_register_nonce",10,1);
function um_custom_disable_register_nonce( $disable ){
return false;
}
?>
@champsupertramp
champsupertramp / WPML + Ultimate Member date translation
Created May 9, 2017 00:29
WPML + Ultimate Member date translation
<?php
add_filter( 'option_date_format', 'translate_date_format', 10, 1 );
function translate_date_format( $format ) {
do_action( 'wpml_register_single_string', 'Date Formats', 'date format', $format );
$format = apply_filters( 'wpml_translate_single_string', $format, 'Date Formats', 'date format' );
return $format;
}
​// remove the existing filter on init
remove_filter( 'um_profile_field_filter_hook__user_registered', 'um_profile_field_filter_hook__user_registered', 99 );