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 a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

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

Let's Talk