Hot answers tagged

18

This should do the trick // removes the `profile.php` admin color scheme options remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); if ( ! function_exists( 'cor_remove_personal_options' ) ) { /** * Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options. */ function cor_remove_personal_options( ...


16

There is no dedicated hook – user management is a low priority in WordPress. You have to use output buffering (yes, not nice). Here is a simple demonstration how this could be done: 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 ...


11

For an author's profile link, use bp_core_get_user_domain( $user_id ) to get the URL, and bp_core_get_userlink( $user_id ) to get an HTML link element, including display name. For the xprofile data, use xprofile_get_field_data( $field, $user_id ) $field can be either the name of the field (like 'Biography') or the numerical field id.


9

Though the user_contactmethods filter is the one of the few for the user profile screen, since the other fields are not required in WordPress, you could use jQuery's .hide() and .remove() to effectively get rid of the ones you don't want without complications in terms of saving the information. Sure, a person without JS on would still see them, but that's a ...


9

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


9

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'] )){ // ...


9

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.


8

There are two ways I've discovered doing this: Author Page with a custom rewrite rule A custom template files paired with a rewrite rule The first is more simple to implement, but may not work in all circumstances (one of which I'll describe soon). Custom Rewrite Rule I found this solution a few days ago here: URL Rewriting And here's the code, with ...


8

For the contact methods filter: user_contactmethods. add_filter( 'user_contactmethods', 'update_contact_methods',10,1); function update_contact_methods( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); return $contactmethods; }


8

You need to use wp_update_user() for the email, as it is not user-meta but core user data. The code should look something like this: $args = array( 'ID' => $current_user->id, 'user_email' => esc_attr( $_POST['user_email'] ) ); wp_update_user( $args ); Note: that's untested, but it should work out of the box.


7

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


6

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


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


5

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


5

Since the asker really doesn’t want to post the answer … someone has to do it: SELECT wp_users.ID , wp_users.user_email FROM wp_users LEFT JOIN wp_bp_xprofile_data ON wp_bp_xprofile_data.user_id = wp_users.ID, WHERE wp_bp_xprofile_data.field_id = 8 AND wp_bp_xprofile_data.value = 'yes' field_id = 8 being the Field you want to get (in my ...


5

function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); } add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' ); For specific user roles you can wrap the add_action in a conditional, something like if(current_user_can('editor')){ add_action( 'wp_before_admin_bar_render', ...


5

great answer, to take this a step further and for anyone looking to apply this to all non-admin users (e.g. contributers, editors etc.) // ===== remove edit profile link from admin bar and side menu and kill profile page if not an admin if( !current_user_can('activate_plugins') ) { function mytheme_admin_bar_render() { global $wp_admin_bar; ...


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

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


4

Ok, I was doing it wrong, here's a working solution, based on Justin Tadlock's tutorial. <?php /* Add custom profile fields (call in theme : echo $curauth->fieldname;) */ add_action( 'show_user_profile', 'my_show_extra_profile_fields' ); add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); function my_show_extra_profile_fields( $user ...


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

Place the following code in your functions.php <?php add_action( 'show_user_profile', 'show_extra_profile_fields' ); add_action( 'edit_user_profile', 'show_extra_profile_fields' ); function show_extra_profile_fields( $user ) { ?> <h3>Extra profile information</h3> <table class="form-table"> ...


4

Choosing the right template As your "User Profile"-Page is something completely custom and not the admin UI user profile page, I'd suggest to take the uthor posts page instead: get_author_link( true, get_current_user_id() ); Then modify this template. Pretty URls No need to go outside the WP template hierarchy. If you want something like ~/user, then ...


4

You are missing the "checked" value for the inputs <input type="checkbox" name="language" <?php if (get_the_author_meta( 'language', $user->ID) == 'Mandarin' ) { ?>checked="checked"<?php }?> value="Mandarin" /> Mandarin<br /> Also, the usermeta is dealing but your are checking for $_POST['gender'] Finally, you should have one ...


4

you can save the 1000 conditional checks by using str_replace and your code would be much more efficient, something like this: //create the select options $options =''; for($i=1;$i<=1000;$i++) { $options.= '<option value="'.$i.'">'.$i.'</option>'; } //get the saved data $saved = get_the_author_meta( 'number_pick', $user->ID ); $saved ...


4

It's entirely possible that you are calling the_author_meta() from outside of your post loop in the author.php template in which case the above will not work. Instead, you can use get_the_author_meta('facebook') or... get_the_author_meta('facebook', $user_id) where $user_id is the ID# of the current user/author. To get the user ID you can do this; ...


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


4

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


4

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


4

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



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