Short of creating a custom registration page, there are not much hooks that can be used to add custom fields to the default form. I tried once (with register_form
hook) and only default fields (description, website, etc) were successfully recognized and saved.
Found this Q&A that has a workaround: Adding extra info via GET while registeration in wordpress
Here’s a proof of concept:
// REGISTRATION
add_action( 'register_form', 'signup_fields_wpse_87261' );
add_action( 'user_register', 'handle_signup_wpse_87261', 10, 2 );
// PROFILE
add_action( 'show_user_profile', 'user_field_wpse_87261' );
add_action( 'personal_options_update', 'save_profile_fields_87261' );
// USER EDIT
add_action( 'edit_user_profile', 'user_field_wpse_87261' );
add_action( 'edit_user_profile_update', 'save_profile_fields_87261' );
function signup_fields_wpse_87261() {
?>
<label>
<input type="checkbox" name="custom_feature_a" id="custom_feature_a" />
Enable feature A?
</label>
<br />
<label>
<input type="checkbox" name="custom_feature_b" id="custom_feature_b" />
Enable feature B?
</label>
<hr />
<?php
}
function handle_signup_wpse_87261( $user_id, $data = null )
{
$feat_a = isset( $_POST['custom_feature_a'] ) ? $_POST['custom_feature_a'] : false;
$feat_b = isset( $_POST['custom_feature_b'] ) ? $_POST['custom_feature_b'] : false;
if ( $feat_a )
{
add_user_meta( $user_id, 'custom_feature_a', $feat_a );
}
if ( $feat_b )
{
add_user_meta( $user_id, 'custom_feature_b', $feat_b );
}
}
function user_field_wpse_87261( $user )
{
$feat_a = get_user_meta( $user->ID, 'custom_feature_a', true );
$feat_b = get_user_meta( $user->ID, 'custom_feature_b', true );
?>
<h3><?php _e('Custom Fields'); ?></h3>
<table class="form-table">
<tr>
<td>
<label><?php
printf(
'<input type="checkbox" name="custom_feature_a" id="custom_feature_a" %1$s />',
checked( $feat_a, 'on', false )
);
?>
<span class="description"><?php _e('Custom Feature A?'); ?></span>
</label>
</td>
</tr>
<tr>
<td>
<label><?php
printf(
'<input type="checkbox" name="custom_feature_b" id="custom_feature_b" %1$s />',
checked( $feat_b, 'on', false )
);
?>
<span class="description"><?php _e('Custom Feature B?'); ?></span>
</label>
</td>
</tr>
</table>
<?php
}
function save_profile_fields_87261( $user_id )
{
$feat_a = isset( $_POST['custom_feature_a'] ) ? $_POST['custom_feature_a'] : false;
$feat_b = isset( $_POST['custom_feature_b'] ) ? $_POST['custom_feature_b'] : false;
update_usermeta( $user_id, 'custom_feature_a', $feat_a );
update_usermeta( $user_id, 'custom_feature_b', $feat_b );
}