Justin Tadlock published a piece of code I needed recently. This snippet allows you to add any fields to the user’s profile page.
<?php
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 ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="twitter">Classes</label></th>
<td>
<input type="text" name="classes" id="classes" value="<?php echo esc_attr( get_the_author_meta( 'classes', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your Classes' URL</span>
</td>
</tr>
</table>
<?php }
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
/* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
update_usermeta( $user_id, 'classes', $_POST['classes'] );
}
?>
Just copy and paste the code in to the functions.php.
Hi ,
I want to add a ‘Add New Page’ Link on the user profile page which allow user to add a new page on that blog.
How can i do that.
i Would really appreciate if you could reply me on shashank.garg86@gmail.com
Thanks and Regards,
Shashank Garg