Skip to content

Instantly share code, notes, and snippets.

View wp-user-manager's full-sized avatar

wp-user-manager

View GitHub Profile
@wp-user-manager
wp-user-manager / wpum_move_role_dropdown_to_top.php
Created December 19, 2019 22:35
How to move the role dropdown to the top of the form
<?php
add_filter( 'wpum_get_registration_fields', 'my_wpum_get_registration_fields' );
function my_wpum_get_registration_fields( $fields ) {
if ( isset( $fields['role'] ) ) {
$fields['role']['priority'] = - 1;
}
return $fields;
}
@wp-user-manager
wp-user-manager / wpum_customize_admin_email_new_user.php
Created January 9, 2020 11:13
WP User Manager - Add all custom field data the user enters on registration to the email sent to the administrator
<?php
add_filter( 'wpum_admin_registration_confirmation_email_headers', function() {
return array('Content-Type: text/html; charset=UTF-8');
});
add_filter('wpum_admin_registration_confirmation_email_message', function( $message, $user ) {
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
$message = sprintf( esc_html__( 'You have a new member application for the %s:', 'wp-user-manager' ), $blogname ) . "<br><br>";
@wp-user-manager
wp-user-manager / wpum_add_external_link_to_profile_tabs.php
Created February 2, 2020 21:42
WP User Manager - Add an external link to the Profile page tabs
@wp-user-manager
wp-user-manager / bookings.php
Last active February 12, 2020 12:45
WP User Manager - Create a new tab on the Profile page and add custom content to it
<?php
// This file should live in
// wp-content/mu-plugins/wpum-templates/profiles/bookings.php
// Output your custom content
@wp-user-manager
wp-user-manager / wpum_directory_search_fields.php
Created February 14, 2020 09:48
WP User Manager - Add other fields to be included in the user directory search
<?php
add_filter( 'wpum_directory_search_meta_keys', function( $keys ) {
$keys[] = 'description';
return $keys;
} );
@wp-user-manager
wp-user-manager / wpum_rename_profile_tabs.php
Created February 19, 2020 16:51
WP User Manager - Rename tabs on the profile page
<?php
add_filter( 'wpum_get_registered_profile_tabs', 'my_wpum_get_registered_profile_tabs' );
function my_wpum_get_registered_profile_tabs( $tabs ) {
$tabs['about']['name'] = esc_html( 'About Me' );
$tabs['posts']['name'] = esc_html( 'My Posts' );
return $tabs;
}
<?php
add_filter( 'account_page_form_fields', function ( $fields ) {
if ( ! wp_verify_nonce( $_POST['account_update_nonce'], 'verify_account_form' ) ) {
return $fields;
}
/**
* Changed this array to the field keys (wpum_ is the prefix)
*/
@wp-user-manager
wp-user-manager / wpum_change_account_settings_tab.php
Created March 9, 2020 10:27
WP User Manager - Change the account page 'Settings' tab to 'Profile'
<?php
function wpum_account_change_settings_tab_name( $tabs ) {
$tabs['settings']['name'] = esc_html( 'Profile' );
return $tabs;
}
add_filter( 'wpum_get_account_page_tabs', 'wpum_account_change_settings_tab_name' );
@wp-user-manager
wp-user-manager / wpum_conditional_account_tabs.php
Created March 20, 2020 12:54
WP User Manager - Conditionally show/hide account tabs based on role
<?php
function wpum_account_tab_changes( $tabs ) {
$tabs['settings']['name'] = esc_html( 'User Details' );
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
unset( $tabs['institution-detail'] );
$tabs['individual-detail']['name'] = esc_html( 'Additional Information' );
}
@wp-user-manager
wp-user-manager / wpum_customize_new_user_registration_email.php
Last active April 10, 2020 07:47
WP User Manager - Customize the new user registration admin email
<?php
// Add this file to the wp-content/mu-plugins directory. The mu-plugins directory might need to be created.
/**
* Send the new user registered email to other email addresses
*/
add_filter( 'wpum_admin_registration_confirmation_email_recipient', function ( $to_email ) {
return $to_email . ',someotheremail@gmail.com';
} );