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
/* | |
You need to hook into um_submit_form_errors_hook with a | |
priority over 10. | |
You can stop registration here if the customer_code field does not | |
match the value you want "ALLOWED_VALUE" in this example | |
*/ |
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
$users = get_users( array('fields' => 'ID') ); | |
foreach( $users as $user_id ) { | |
delete_user_meta( $user_id, 'display_name' ); | |
} |
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_submit_form_errors_hook', 'check_customer_code', 100 ); | |
function check_customer_code( $args ){ | |
if ( isset( $args['customer_code'] ) && $args['customer_code'] != 'ABCDE' ) | |
exit( wp_redirect( add_query_arg('err', 'invalid_customer_code') ) ); | |
} |
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 is a sample filter that assumes your textfield meta key is "buttoncode" | |
The filter below allow you to change the output dynamically | |
to show a shortcode instead of the value entered for that field | |
Use in theme functions.php and do not have to rely on UM core | |
*/ |
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_account_pre_update_profile', 'did_user_change_email', 10, 2 ); | |
function did_user_change_email( $changes, $user_id ) { | |
$data = get_userdata($user_id); | |
if ( isset( $changes['user_email'] ) && $data->user_email != $changes['user_email'] ) { | |
// user e-mail changed! Do something | |
} | |
} |
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; | |
} | |
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', | |
); | |
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" />'; | |
} |
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'); |
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 example syncs both UM / WP role during user approval */ | |
add_action('um_after_user_is_approved', 'sync_um_and_wp_role', 99 ); | |
function sync_um_and_wp_role( $user_id ) { | |
// Get UM role | |
$role = get_user_meta( $user_id, 'role', true ); | |
// Set WordPress role for same user | |
$wp_user_object = new WP_User( $user_id ); |
OlderNewer