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 - Disable nonce in registration form
Created Apr 19, 2017
Ultimate Member - Disable nonce in registration form
View 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;
}
?>
View 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 );
@champsupertramp
champsupertramp / Ultimate Member - Change date format to timestamp
Created May 10, 2017
Ultimate Member - Change date format to timestamp
View Ultimate Member - Change date format to timestamp
<?php
add_filter('um_user_pre_updating_profile_array','um_custom_user_pre_updating_profile_array');
function um_custom_user_pre_updating_profile_array( $arr ){
global $ultimatemember;
foreach ($arr as $key => $value) {
$field = $ultimatemember->fields->get_field( $key );
if( $field['type'] == 'date' && ! empty( $value ) ){
$arr[ $key ] = strtotime( $value );
}
View Ultimate Member - Change date format in front-end
<?php
/**
* Change Date format in front-end
*/
add_filter('um_profile_field_filter_hook__date','my_custom_sanitize_fields', 9999, 2 );
function my_custom_sanitize_fields( $value, $data ){
global $ultimatemember;
if( $data['metakey'] == 'date-pickah' ){
$value = $ultimatemember->datetime->format( $value, "d M Y");
@champsupertramp
champsupertramp / Ultimate Member Woocommerce extension - Change User Status on completed or successful transaction
Created Aug 18, 2016
Ultimate Member Woocommerce extension - Change User Status on completed or successful transaction
View Ultimate Member Woocommerce extension - Change User Status on completed or successful transaction
<?php
add_action('woocommerce_order_status_completed', 'um_woocommerce_approve_user_status');
function um_woocommerce_approve_user_status( $order_id ){
global $ultimatemember;
$order = new WC_Order( $order_id );
$user_id = (int)$order->user_id;
$items = $order->get_items();
um_fetch_user( $user_id );
@champsupertramp
champsupertramp / gist:d3e252763eb0adf9fe7b
Last active Nov 13, 2017 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
View gist:d3e252763eb0adf9fe7b
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@champsupertramp
champsupertramp / um-reviews-adjust-rating-stats.php
Last active Nov 29, 2017
Ultimate Member User Reviews - Adjust rating stats
View um-reviews-adjust-rating-stats.php
<?php
function um_custom_review_adjust_rating( $post_id, $old_rating, $new_rating, $new_user_id, $new_reviewer_id ) {
update_post_meta( $post_id, '_rating', $new_rating );
$old_user_id = get_post_meta( $post_id, '_user_id', true );
$old_reviewer_id = get_post_meta( $post_id, '_reviewer_id', true );
update_post_meta( $post_id, '_reviewer_id', $new_reviewer_id );
update_post_meta( $post_id, '_user_id', $new_user_id );
@champsupertramp
champsupertramp / Fix Ultimate Member compatibility issue with Eduma Theme
Created Mar 8, 2017
Fix Ultimate Member compatibility issue with Eduma Theme
View Fix Ultimate Member compatibility issue with Eduma Theme
<?php
add_action("init","um_custom_remove_conflicting_actions", 999999 );
function um_custom_remove_conflicting_actions(){
remove_action( 'signup_header', 'thim_multisite_signup_redirect' );
remove_action( 'user_register', 'thim_register_extra_fields', 1000 );
remove_action( 'register_post', 'thim_check_extra_register_fields', 10 );
remove_action( 'register_post', 'thim_register_failed', 99 );
}
?>
View Ultimate Member - Integrate Co-author plus plugin
<?php
/***
*** @integrate co-author plus with Ultimate Member
***/
function um_integrate_coauthor( $args ){
global $ultimatemember;
$posts_query = $ultimatemember->query->make('post_type=post&posts_per_page=12&offset=0&author_name=' . um_user('user_login') );
return $posts_query;
View Ultimate Member - Get User Meta
<?php
/***
*** @Get User Meta
***/
// You can set the user id to retrieve the meta key value
// global $ultimatemember;
// $ultimatemember->user->set( $user_ID );
echo um_user('first_name');
// You can check some useful meta keys/values that you can
// retrieve with the above function here: https://codex.wordpress.org/Function_Reference/get_userdata#Notes