Create new profile fields

<?php
/**
* User Fields
*
* Added to User Profile, and used by Editors widget
*
* @package BE_Genesis_Child
* @author Bill Erickson <[email protected]>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
add_action( 'show_user_profile', 'be_team_fields' );
add_action( 'edit_user_profile', 'be_team_fields' );
/**
* Add Author Profile Fields to User Profile
* @author Bill Erickson
*
* @param object $user
*/
function be_team_fields( $user ) {
// Limit to Admins
//if( !current_user_can( 'create_users' ) )
// return;
?>
<h3>Author Profile</h3>
<p class="description">Displayed on your archive page and the team page.</p>
<table class="form-table">
<tr style="width: 700px; display: block;">
<th><label for="be_team_title">Title</label></th>
<td>
<input type="text" name="be_team_title" id="be_team_title" value="<?php echo esc_attr( get_the_author_meta( 'be_team_title', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr style="width: 700px; display: block;">
<th><label for="be_team_long_description">Long Description</label></th>
<td>
<?php wp_editor( get_the_author_meta( 'be_team_long_description', $user->ID ), 'be_team_long_description', array( 'media_buttons' => false ) ); ?>
</td>
</tr>
</table>
<?php }
add_action( 'personal_options_update', 'be_save_team_fields' );
add_action( 'edit_user_profile_update', 'be_save_team_fields' );
/**
* Save Author Profile Fields
* @author Bill Erickson
*
* @param int $user_id
*/
function be_save_team_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_user_meta( $user_id, 'be_team_title', $_POST['be_team_title'] );
update_user_meta( $user_id, 'be_team_long_description', $_POST['be_team_long_description'] );
}
view raw gistfile1.aw hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk