您可以在以下网址阅读内容广泛的教程:
http://www.cozmoslabs.com/1012-wordpress-user-registration-template-and-custom-user-profile-fields/
基本上,这是您将用来将它们添加到后端的内容:
add_action( \'show_user_profile\', \'show_extra_profile_fields\', 10 );
add_action( \'edit_user_profile\', \'show_extra_profile_fields\', 10 );
function show_extra_profile_fields( $user ) { ?>
<input type="text" name="twitter" value="<?php echo esc_attr( get_the_author_meta( \'twitter\', $user->ID ) ); ?>" />
<?php }
并在用户或管理员更新配置文件时保存它们:
add_action( \'personal_options_update\', \'save_extra_profile_fields\' );
add_action( \'edit_user_profile_update\', \'save_extra_profile_fields\' );
function save_extra_profile_fields( $user_id ) {
if ( !current_user_can( \'edit_user\', $user_id ) )
return false;
update_usermeta( $user_id, \'twitter\', $_POST[\'twitter\'] );
}
下一步是将这些额外字段添加/保存到正在构建和使用的表单中:
update_usermeta( $new_user, \'twitter\', esc_attr( $_POST[\'twitter\'] ) );
在用户注册时从前端保存它们。