Created
February 10, 2012 21:14
-
-
Save billerickson/1792931 to your computer and use it in GitHub Desktop.
Create user profile fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* User Fields | |
* | |
* Added to User Profile, and used by Editors widget | |
* | |
* @package BE_Genesis_Child | |
* @author Bill Erickson <bill@billerickson.net> | |
* @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'] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment