16

If you plan to use this code on frontend, I would check if email is free to use. Otherwise, you are creating a security hole. if (isset( $_POST['email'])) { // check if user is really updating the value if ($user_email != $_POST['email']) { // check if email is free to use if (email_exists( $_POST['email'] )){ // ...


12

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: ...


11

You technically don't have to set a nickname, it will be filled with your username if you clear the field out. Display name is selectable between the user's username, first name, last name, first/last, or last/first, or nickname. The nickname exists to give you an option to set display name to something other than your username or real name.


9

Default WordPress uses Gravatar, you can find more information about it here. On WordPress.com, we use Gravatar to associate an avatar with a user’s account. If you’ve set up a Gravatar, it will be displayed when you post to the forums or comment on a blog, and it may also appear if your blog is featured on a tag page. Custom - Backend If you manually want ...


9

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 ...


7

Since the recent class change this works: add_action( 'personal_options', array ( 'T5_Hide_Profile_Bio_Box', 'start' ) ); /** * Captures the part with the biobox in an output buffer and removes it. * * @author Thomas Scholz, <info@toscho.de> * */ class T5_Hide_Profile_Bio_Box { /** * Called on 'personal_options'. * * @return ...


7

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; ...


7

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 where the display_name already ...


7

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 ...


6

Was just trying to figure this out and came across this answer. The above code by Cor van doesn't work anymore, but with a slight change of the add_action, it can. All you need to do is change the last two lines from: add_action( 'admin_head-profile.php', 'cor_profile_subject_start' ); add_action( 'admin_footer-profile.php', 'cor_profile_subject_end' ); ...


6

You should (if available) submit the code you are working with, even if just a snippet, so we can assess your process in relation to your question. The short answer however is YES, it is safe, so long as you, prevent input fields being displayed on user profile page for certain user roles prevent unauthorized users from saving user meta to the database ...


6

Presuming that the user has their avatar saved, as the ID of an attachment, store in user meta, as the field field_with_custom_avatar_id, you could do this to show that attachment if the value is saved: add_filter( 'get_avatar', 'slug_get_avatar', 10, 5 ); function slug_get_avatar( $avatar, $id_or_email, $size, $default, $alt ) { //If is email, try ...


5

Accepted answer is not working with 4.8 Here comes an up to date and simplified code that should work with any version: // removes admin color scheme options remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); //Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options. ...


5

Solution as a (MU-)Plugin I checked all the provided solutions and thought I could make a nice MU-Plugin out of it. The only real change is that it avoids <?php ! defined( 'ABSPATH' ) AND exit; /** * Plugin Name: Disable profile page link * Description: Remove edit profile link from admin bar and side menu and kill profile page if user isn't an ...


5

Files named "core" are created when some OS process crashes. In your case it was likely a crash of the php interpreter. These files being memory dumps are used to debug the process "postmortem" - e.g. to check in which function did it fail, so it is perfectly safe to delete them if you are not going to debug the issue. In fact, on many systems there is a ...


5

You can do this using either the personal_options_update or edit_user_profile_update hook depending on what exactly you want to do. If those aren't firing when you need, you can poke around in http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/user-edit.php to find a different hook to use. See Justin Tadlock's tutorial for more


5

I have written a solution for that some time ago: <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Comment author URI to blog author page * Description: Changes the comment author URI to the blog’s author archive * Version: 2012.07.18 * Author: Fuxia Scholz * Author URI: https://fuxia.me * License: MIT * License URI: http://www....


5

I resolved the problem with ob_ functions and DOMDocument. It's better than jQuery or CSS for protecting the form. I use this kind of solution every time when I can't access a part of HTML content through a hook. function remove_extra_field_profile() { $current_file_url = preg_replace( "#\?.*#" , "" , basename( $_SERVER['REQUEST_URI'] ) ); if( $...


5

You can use the WP_User class and the has_cap($role) method. The show_user_profile action passes a WP_User object as a parameter to the called function. http://codex.wordpress.org/Class_Reference/WP_User#has_cap.28.24cap.29 add_action('show_user_profile', 'my_add_extra_profile_fields'); function my_add_extra_profile_fields($user) { if ($user->...


5

The hook you need is the get_avatar filter. It returs the image HTML element representing the user avatar. add_filter( 'get_avatar', 'cyb_get_avatar', 10, 5 ); function cyb_get_avatar( $avatar = '', $id_or_email, $size = 96, $default = '', $alt = '' ) { // Replace $avatar with your own image element, for example // $avatar = "<img alt='$alt' src=...


5

Add this code in functions.php add_action( 'register_form', 'myplugin_register_form' ); function myplugin_register_form() { $first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : ''; $last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : ''; ?> <p> <label ...


4

I found this: Exclude Users from Members directory on a BuddyPress based social network We will need to hook to 'bp_ajax_querystring' filter. The following code will allow to exclude the users from the members directory. They will be still listed in the friends list of other users with whom they are friends with. add_action('bp_ajax_querystring','...


4

The simplest and most lightweight solution is to use CSS to just hide it from view. .user-description-wrap { display: none; }


4

Try instead $user_contactmethods['work'] = __('I work for...'); and <?php echo get_user_meta($current_user->ID,'work',true);?> where the array index is 'work' instead of 'I work for...', i.e. lowercase and without any spaces.


4

It seems as if the hook personal_options_update might be what you're looking for. add_action( 'personal_options_update', 'my_custom_func' ); function my_custom_func( $user_id /* if you need that */ ) { ... }


4

First of all register the cpt. Probably if you don't want add the UI for that post type you can set the show_ui to false. $args = array( 'label' => 'Members', 'public' => true, 'exclude_from_search' => true, 'show_ui' => false, 'show_in_nav_menus' => false, 'show_in_menu' => false, 'show_in_admin_bar' => false, '...


4

At the moment (3.8) color schemes do not apply to admin bar at front end at all, even if user is logged in and has non-default scheme selected. The shortest way would probably be to force enqueue color scheme at front end: add_action( 'wp_enqueue_scripts', function () { wp_enqueue_style( 'color-admin-bar', admin_url( ...


4

update_option( $name, $side_ad ); Your issue here is that update_option stores the value in the options table of the site. However you're on a multisite, and your install contains multiple sites/blogs, each with their own options tables. As a result, editing a user on blog/site A will not change the option on blog/site B, in the same way that painting a ...


4

Here's one way to hide it with CSS: add_action( 'personal_options', function( $profileuser ) { ?><style>.show-admin-bar{ display: none;}</style><?php } ); or rather place it within the <head>...</head> with: add_action( 'admin_print_styles-user-edit.php', 'wpse_hide_admin_bar_settings' ); add_action( 'admin_print_styles-...


4

I think you want something like this: <textarea type="text" name="twitter" id="twitter" class="regular-text"><?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?></textarea> Note, the input field has a value attribute while the textarea has it's content between <textarea> and </textarea>


Only top voted, non community-wiki answers of a minimum length are eligible