WordPress tutorial, add custom fields to user profile wordpress without plugin. For adding extra details use can use following sample code in functions.php file. You can modify the code as per your requirement.
add custom fields to user profile wordpress without plugin
Note: If you are not wordpress developer then you should ask any wordpress developer to do this changes.
add_action( 'show_user_profile', 'extra_fields_to_user' ); add_action( 'edit_user_profile', 'extra_fields_to_user' ); function extra_fields_to_user( $user ) { ?> <h3>Extra profile information</h3> <table> <tr> <th><label for="facebook">facebook</label></th> <td> <input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" /><br /> <span>Please enter your facebook username.</span> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'extra_fields_to_user_save' ); add_action( 'edit_user_profile_update', 'extra_fields_to_user_save' ); function extra_fields_to_user_save( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) return false; /* Copy and paste this line for additional fields. Make sure to change 'facebook' to the field ID. */ update_usermeta( $user_id, 'facebook', $_POST['facebook'] ); }
showing the user information use following code.
<?php the_author_meta( ‘facebook’ ); ?>
How to add custom image field to users details? That would be very helpful if someone wanted to have image/avatar for authors..