View gist:66259b3282b232a5b447
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global $um_messaging; | |
$user_id = 'xx'; // enter user id here | |
$count = $um_messaging->api->get_unread_count( $user_id ); | |
echo $count; |
View gist:f7eab149cb33df735b08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* add new tab called "mytab" */ | |
add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 ); | |
function my_custom_tab_in_um( $tabs ) { | |
$tabs[800]['mytab']['icon'] = 'um-faicon-pencil'; | |
$tabs[800]['mytab']['title'] = 'My Custom Tab'; | |
$tabs[800]['mytab']['custom'] = true; | |
return $tabs; | |
} | |
View gist:78aac8b268b2c75489f0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
View gist:8cdaf61e7bd9de35512c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* First we need to extend main profile tabs */ | |
add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 ); | |
function add_custom_profile_tab( $tabs ) { | |
$tabs['mycustomtab'] = array( | |
'name' => 'My custom tab', | |
'icon' => 'um-faicon-comments', | |
); | |
View gist:44d89249baf9f73b89d6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ); |
View gist:643cd90967e5e415378d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
} |
View gist:1d81b59cd8b21f67b36c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('um_after_register_fields', 'add_a_hidden_field_to_register'); | |
function add_a_hidden_field_to_register( $args ){ | |
echo '<input type="hidden" name="field_id" id="field_id" value="HERE_GOES_THE_VALUE" />'; | |
} |
View gist:5f725bff6bcf79d2988e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 | |
*/ |
View gist:d98861b4c14a1540291b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This code will sync the UM role based on WP role using gravity registration */ | |
add_action("gform_user_registered", "um_gravity_user_role_sync", 200, 4); | |
function um_gravity_user_role_sync($user_id, $config, $entry, $user_pass) { | |
$user = new WP_User( $user_id ); | |
$wp_role = $user->roles[0]; | |
// if WP role is subscriber, set UM role to member | |
if ( $wp_role == 'subscriber' ) { |
View gist:5f093ac300baa1d2a5f1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The following code will require @gmail.com as domain | |
for user registrations. | |
You can change @gmail.com to any provider you want. | |
The code below requires a user email to be collected during registration | |
*/ | |
add_action('um_before_new_user_register', 'require_google_email_for_signup'); |
NewerOlder