I found this code that looks very promising:
/**
* Add cutom field to WPMU registration form
*/
add_action('signup_extra_fields','custom_signup_extra_fields', $errors);
// this in an example with a text input
function custom_signup_extra_fields($errors) {
?>
<label for="companyname">Company name: <input id="companyname" class="input" type="text" value="<?php echo esc_attr($_POST['companyname']) ?>" name="companyname"/>
<br />
<label for="e_mail_updates"><input type="checkbox" name="e_mail_updates" id="e_mail_updates" <?php if(isset($_POST['e_mail_updates'])) checked('true', $_POST['e_mail_updates']); ?> value="true" /> I would like to receive e-mail updates
</label>
<br />
<?php
}
/**
* Save custom field input to wp_signups table
*/
add_filter( 'add_signup_meta', 'custom_add_signup_meta' );
function custom_add_signup_meta ( $meta = array() ) {
// create an array of custom meta fields
$meta['custom_usermeta'] = array(
// 'meta_key' => $_POST['input_field'],
'companyname' => $_POST['companyname'],
'e_mail_updates' => $_POST['e_mail_updates']
);
return $meta;
}
/**
* Set new usermeta upon new user activation
*/
add_action( 'wpmu_activate_user', 'custom_add_new_user_meta', 10, 3 );
function custom_add_new_user_meta( $user_id, $email, $meta ) {
if ( $meta['custom_usermeta'] ) {
// loop through array of custom meta fields
foreach ( $meta['custom_usermeta'] as $key => $value ) {
// and set each one as a meta field
update_user_meta( $user_id, $key, $value );
}
}
}
I tried the original from pastebin and my version above with another text field added. Nothing shows up in usermeta unfortunately. Something goes wrong posting the values.
Here’s what ends up in the wp_signups table:
a:3:{s:7:"lang_id";i:1;s:6:"public";i:1;s:15:"custom_usermeta";a:2:{s:11:"companyname";N;s:14:"e_mail_updates";N;}}
I assume the N stands for Null; no data, so nothing to move to usermeta.
Does anyone know how to fix this? Why aren’t the values stored?