Skip to content

Instantly share code, notes, and snippets.

Ultimate Member ultimatemember

Block or report user

Report or block ultimatemember

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ultimatemember
ultimatemember / gist:66259b3282b232a5b447
Last active Sep 29, 2015
Private Messages API: Get number of unread messages for a user
View gist:66259b3282b232a5b447
global $um_messaging;
$user_id = 'xx'; // enter user id here
$count = $um_messaging->api->get_unread_count( $user_id );
echo $count;
@ultimatemember
ultimatemember / gist:873ae0013a15228abb70
Last active Aug 29, 2015
Run a specific action whenever community role is updated
View gist:873ae0013a15228abb70
add_action('um_after_user_role_is_updated', 'mycustom_role_change_action', 10, 2 );
function mycustom_role_change_action( $user_id, $new_role ) {
if ( $new_role == 'admin' ) {
die('You can not be a community admin');
}
}
@ultimatemember
ultimatemember / gist:643cd90967e5e415378d
Last active Mar 10, 2019
Custom profile tab example: showing user pages
View gist:643cd90967e5e415378d
/* add a custom tab to show user pages */
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$tabs['pages'] = array(
'name' => 'Pages',
'icon' => 'um-faicon-pencil',
'custom' => true
);
return $tabs;
}
@ultimatemember
ultimatemember / gist:78aac8b268b2c75489f0
Last active Dec 4, 2017
Apply your own custom validation to a field
View gist:78aac8b268b2c75489f0
/*
In this code sample, you can learn how to apply custom
validations on any fields you want.
This can be done using these steps:
1. Edit the field in backend (field modal)
2. Where it asks for field validation choose "Custom"
3. Enter a unique validation action name e.g. my_8numbers
@ultimatemember
ultimatemember / gist:5f725bff6bcf79d2988e
Last active Aug 21, 2017
Using notifications API to add custom notifications
View gist:5f725bff6bcf79d2988e
/*
This code sample shows you how to use the API to create
and add custom notifications (for real-time notifications)
plugin.
STEP 1: You need to extend the filter: um_notifications_core_log_types with your
new notification type as follows for example
*/
@ultimatemember
ultimatemember / gist:48bf0a269af5d182ad9b
Created May 4, 2015
UM/EDD Open Metrics: Show various sale stats
View gist:48bf0a269af5d182ad9b
// Avg downloads per customer
function sc_edd_avg_downloads_per_customer( $atts ) {
$amount = 0;
$query = new WP_Query( array( 'post_type' => 'download' ) );
foreach( $query->posts as $post ) {
$amount = $amount + edd_get_download_sales_stats( $post->ID );
}
$amount = $amount / edd_count_total_customers();
return number_format( $amount, 2 );
}
@ultimatemember
ultimatemember / gist:afb94c5b66c63a34d3c1
Last active Nov 5, 2015
UM/EDD Open Metrics: Show recent payments
View gist:afb94c5b66c63a34d3c1
// recent payments
function sc_edd_recent_payments( $atts ) {
$p_query = new EDD_Payments_Query( array(
'number' => 12,
'status' => 'publish'
) );
$payments = $p_query->get_payments();
@ultimatemember
ultimatemember / gist:44d89249baf9f73b89d6
Last active May 17, 2018
Using the new RESTful API to process remote queries
View gist:44d89249baf9f73b89d6
// API Request
$url = 'http://localhost/um-api/get.user/?id=1';
// Include your public key and token to the URL
$url = add_query_arg('key', '75d9a913782eee3d990e4464ce26213e', $url );
$url = add_query_arg('token', 'bae6ee38cf02a50a0ac8259eed34ceb9', $url );
// Process your request
$request = wp_remote_get( $url );
$response = json_decode( wp_remote_retrieve_body( $request ) , true );
@ultimatemember
ultimatemember / gist:8743ef32801f7bf08c82
Created Mar 19, 2015
All members to automatically be WP contributors when they sign up via UM
View gist:8743ef32801f7bf08c82
add_action('um_after_user_is_approved', 'wp_role_contributor_after_um', 99 );
function wp_role_contributor_after_um( $user_id ) {
$wp_user_object = new WP_User( $user_id );
$wp_user_object->set_role( 'contributor' );
}
@ultimatemember
ultimatemember / gist:21e10196a0b4aa493fbb
Last active Aug 29, 2015
Updated: Ultimate Member & bbPress Custom CSS
View gist:21e10196a0b4aa493fbb
#bbpress-forums .bbp-forums-list li {
font-size: 12px !important;
margin: 0px 12px 0 0 !important;
}
#bbpress-forums .bbp-forums-list li a {
padding: 1px 4px;
font-size: 12px;
background: #eee;
color: #666;
display: inline-block;
You can’t perform that action at this time.