How to obtain the user ID of the current profile being edited in WP-Admin?

There is a global variable called … $user_id available on that page. Always. From user-edit.php: $user_id = (int) $user_id; $current_user = wp_get_current_user(); if ( ! defined( ‘IS_PROFILE_PAGE’ ) ) define( ‘IS_PROFILE_PAGE’, ( $user_id == $current_user->ID ) ); if ( ! $user_id && IS_PROFILE_PAGE ) $user_id = $current_user->ID; elseif ( ! $user_id && ! IS_PROFILE_PAGE ) … Read more

Which hook if user profile information is updated?

From Codex: Plugin API – Action Reference – profile_update: Note: This hook is not used on user edit/profile pages. To hook into the admin’s user edit pages, use the hook edit_user_profile_update which is located in /wp-includes/user-edit.php instead. From Codex: Plugin API – Action Reference – edit_user_profile_update: This hook only triggers when a user is viewing … Read more

How to disable profile.php for users?

Redirect from profile.php to the dashboard Here’s one way to do it: add_action( ‘load-profile.php’, function() { if( ! current_user_can( ‘manage_options’ ) ) exit( wp_safe_redirect( admin_url() ) ); } ); where we redirect to the dashboard instead, if the current user can’t manage options. Redirect from profile.php to the current user’s member page If you want … Read more

How to display a public profile page for registered users with custom slug?

Every registered user can have profile, they don’t need to have posts. To change WordPress author’s profile permalink, paste the following code in your functions.php: function change_author_permalink_base() { global $wp_rewrite; $wp_rewrite->author_base = “user”; } add_filter( ‘init’, ‘change_author_permalink_base’ ); After pasting the code, visit Settings->Permalink Structure under your wordpress admin, to flush the rewrite rules. This … Read more

How to use tinyMCE for user “biographical info”?

I found a very helpful blog post which shows exactly how to accomplish what I am after with only three small changes to the user-edit.php page. First Change I had to add a class name to the <textarea> tag for the description. <textarea name=”description” id=”description” rows=”5″ cols=”30″ class=”CLASS_NAME_HERE”><?php echo esc_html($profileuser->description); ?> </textarea><br /> Second Change … Read more

Removing “Website” Field from the contact info

Revisited and updated answer: We can’t use the user_contactmethods filter to remove the website wrapper, because this piece is hardcoded in the user-edit.php file and not part of the filterable user contacts loop, generated by: wp_get_user_contact_methods( $profileuser ) Hiding it with CSS The website row element now got it’s own .user-url-wrap class: <tr class=”user-url-wrap”> <th><label … Read more

Make display name unique

As far as I’m aware, all you can do is filter the display name via pre_user_display_name and check if it already exists. Unfortunately WP_User_Query doesn’t support querying by display_name, so we also have to add to the WHERE clause via pre_user_query. Additionally, there is no elegant way I can think of to handle the case … Read more