How to add new custom field in default add user form through plugin

It is possible. For that we will use 4 hooks (actions): show_user_profile, edit_user_profile, personal_options_update, edit_user_profile_update. Here is the example how to add extra field to user in WordPress. Adding user info fields function add_action( ‘show_user_profile’, ‘extra_user_profile_fields’, 10, 1 ); add_action( ‘edit_user_profile’, ‘extra_user_profile_fields’, 10, 1 ); function extra_user_profile_fields( $user ) { ?> <h3><?php _e(“Extra profile information”, … Read more

Front end user meta options for users

“edit_user_profile_update” is not an action… check: http://codex.wordpress.org/Plugin_API/Action_Reference update_usermeta() is deprecated in wp 3 and above, use update_user_meta() your form is lacking some standard hidden fields like: <input type=”hidden” name=”user_id” id=”user_id” value=”<?php echo esc_attr( $current_user->ID ); ?>” /> use wp_nonce_field(); ex: <?php wp_nonce_field( ‘update-user_’ . $current_user->ID ) ?>

Check if user is online?

WordPress doesn’t track if a user is online. It can only know if the current is online, which is always yes ( else there would be no request ). If you want to know if a different user that isn’t the current user is online, that information doesn’t exist, and you’ll need to implement it … Read more

Redirecting user after updating profile?

This is the function that you need: add_action( ‘profile_update’, ‘custom_profile_redirect’, 12 ); function custom_profile_redirect() { if(is_admin()): wp_redirect( trailingslashit( home_url() ) ); exit; endif; } Just change the target of wp_redirect to whatever URL you want your users to go to. You can even add conditional logic to it if you only want this to happen … Read more

How to list users that have written custom post types and hide the ones that have not?

wp_list_authors(), internally gets posts that are only of type post. See line 294 http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/author-template.php#L273 As you have noted, this answer is great and with some modification can do what you want. function wpse31443_author_has_custom_post_type( $post_author, $post_type ) { global $wp_post_types; // If nonexistent post type found return if ( array_intersect((array)$post_type, array_keys($wp_post_types)) != (array)$post_type ) return false; … Read more

WordPress edit_user_profile_update update secondary role

I have finally found solution and the right hook for this: profile_update is called at the end of wp_insert_user in user.php which is called from edit_user. wp_insert_user ending: if ( $update ) do_action(‘profile_update’, $user_id, $old_user_data); else do_action(‘user_register’, $user_id); return $user_id;

User profile custom field

Here is an example using a field called my_field. The value is successfully saved and displayed: // Declaring the form fields add_action( ‘show_user_profile’, ‘wpse_show_my_fields’ ); add_action( ‘edit_user_profile’, ‘wpse_show_my_fields’ ); add_action( ‘user_new_form’, ‘wpse_show_my_fields’ ); function wpse_show_my_fields( $user ) { $fetched_field = get_user_meta( $user->ID, ‘my_field’, true ); ?> <tr class=”form-field”> <th scope=”row”><label for=”my_field”><?php _e( ‘Field Name’, ‘text-domain’ … Read more