// Hooks near the bottom of profile page (if current user)
add_action('show_user_profile', 'custom_user_profile_fields');
// Hooks near the bottom of the profile page (if not current user)
add_action('edit_user_profile', 'custom_user_profile_fields');
// @param WP_User $user
function custom_user_profile_fields( $user ) {
?>
<table class="form-table">
<tr>
<th>
<label for="code"><?php _e( 'App Store Link to VR App' ); ?></label>
</th>
<td>
<input type="text" name="user_app_store_link" id="user_app_store_link" value="<?php echo esc_attr( get_the_author_meta( 'user_app_store_link', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th>
<label for="code"><?php _e( 'How did you find Vertebrae?' ); ?></label>
</th>
<td>
<input type="text" name="find_vertebrae" id="find_vertebrae" value="<?php echo esc_attr( get_the_author_meta( 'find_vertebrae', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th>
<label for="code"><?php _e( 'Company Name' ); ?></label>
</th>
<td>
<input type="text" name="company_name" id="company_name" value="<?php echo esc_attr( get_the_author_meta( 'company_name', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th>
<label for="code"><?php _e( 'User Website' ); ?></label>
</th>
<td>
<input type="text" name="user_website" id="user_website" value="<?php echo esc_attr( get_the_author_meta( 'user_website', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
</table>
<?php
}
// Hook is used to save custom fields that have been added to the WordPress profile page (if current user)
add_action( 'personal_options_update', 'update_extra_profile_fields' );
// Hook is used to save custom fields that have been added to the WordPress profile page (if not current user)
add_action( 'edit_user_profile_update', 'update_extra_profile_fields' );
function update_extra_profile_fields( $user_id ) {
if ( current_user_can( 'edit_user', $user_id ) )
update_user_meta( $user_id, 'user_app_store_link', $_POST['user_app_store_link'] );
update_user_meta( $user_id, 'find_vertebrae', $_POST['find_vertebrae'] );
update_user_meta( $user_id, 'company_name', $_POST['company_name'] );
update_user_meta( $user_id, 'user_website', $_POST['user_website'] );
}
add_action('show_user_profile', 'custom_user_profile_fields');
// Hooks near the bottom of the profile page (if not current user)
add_action('edit_user_profile', 'custom_user_profile_fields');
// @param WP_User $user
function custom_user_profile_fields( $user ) {
?>
<table class="form-table">
<tr>
<th>
<label for="code"><?php _e( 'App Store Link to VR App' ); ?></label>
</th>
<td>
<input type="text" name="user_app_store_link" id="user_app_store_link" value="<?php echo esc_attr( get_the_author_meta( 'user_app_store_link', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th>
<label for="code"><?php _e( 'How did you find Vertebrae?' ); ?></label>
</th>
<td>
<input type="text" name="find_vertebrae" id="find_vertebrae" value="<?php echo esc_attr( get_the_author_meta( 'find_vertebrae', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th>
<label for="code"><?php _e( 'Company Name' ); ?></label>
</th>
<td>
<input type="text" name="company_name" id="company_name" value="<?php echo esc_attr( get_the_author_meta( 'company_name', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th>
<label for="code"><?php _e( 'User Website' ); ?></label>
</th>
<td>
<input type="text" name="user_website" id="user_website" value="<?php echo esc_attr( get_the_author_meta( 'user_website', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
</table>
<?php
}
// Hook is used to save custom fields that have been added to the WordPress profile page (if current user)
add_action( 'personal_options_update', 'update_extra_profile_fields' );
// Hook is used to save custom fields that have been added to the WordPress profile page (if not current user)
add_action( 'edit_user_profile_update', 'update_extra_profile_fields' );
function update_extra_profile_fields( $user_id ) {
if ( current_user_can( 'edit_user', $user_id ) )
update_user_meta( $user_id, 'user_app_store_link', $_POST['user_app_store_link'] );
update_user_meta( $user_id, 'find_vertebrae', $_POST['find_vertebrae'] );
update_user_meta( $user_id, 'company_name', $_POST['company_name'] );
update_user_meta( $user_id, 'user_website', $_POST['user_website'] );
}
Comments
Post a Comment