This is the code for the form in functions.php:
// Registration & Login Forms
// ---------------------------
add_action( 'register_form', 'ra_extra_reg_fields', 1 );
function ra_extra_reg_fields() { ?>
<p>
<label>First Name<br/>
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( $_POST['first_name'] ); ?>" size="25"/>
</label>
</p>
<p>
<label>Last Name<br/>
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( $_POST['last_name'] ); ?>" size="25" />
</label>
</p>
<p>
<label>School/Library Name<br/>
<input type="text" name="organisation" id="organisation" class="input" value="<?php echo esc_attr( $_POST['organisation'] ); ?>" size="25" />
</label>
</p>
<p>
<label>State<br/>
<select id="state" name="state">
<option value=""></option>
<option <?php if ( $_POST['state'] == 'ACT' ) echo 'selected'; ?>>ACT</option>
<option <?php if ( $_POST['state'] == 'NSW' ) echo 'selected'; ?>>NSW</option>
<option <?php if ( $_POST['state'] == 'NT' ) echo 'selected'; ?>>NT</option>
<option <?php if ( $_POST['state'] == 'QLD' ) echo 'selected'; ?>>QLD</option>
<option <?php if ( $_POST['state'] == 'SA' ) echo 'selected'; ?>>SA</option>
<option <?php if ( $_POST['state'] == 'TAS' ) echo 'selected'; ?>>TAS</option>
<option <?php if ( $_POST['state'] == 'WA' ) echo 'selected'; ?>>WA</option>
<option <?php if ( $_POST['state'] == 'VIC' ) echo 'selected'; ?>>VIC</option>
<option <?php if ( $_POST['state'] == 'Other' ) echo 'selected'; ?>>Other</option>
</select>
</label>
</p>
<p>
<label>About You<br/>
<select id="aboutyou" name="aboutyou">
<option value=""></option>
<option <?php if ( $_POST['aboutyou'] == 'Teacher - Primary' ) echo 'selected'; ?>>Teacher - Primary</option>
<option <?php if ( $_POST['aboutyou'] == 'Teacher - Secondary' ) echo 'selected'; ?>>Teacher - Secondary</option>
<option <?php if ( $_POST['aboutyou'] == 'Teacher - Tertiary' ) echo 'selected'; ?>>Teacher - Tertiary</option>
<option <?php if ( $_POST['aboutyou'] == 'Librarian' ) echo 'selected'; ?>>Librarian</option>
<option <?php if ( $_POST['aboutyou'] == 'Academic' ) echo 'selected'; ?>>Academic</option>
<option <?php if ( $_POST['aboutyou'] == 'Avid reade' ) echo 'selected'; ?>>Avid reader</option>
</select>
</label>
</p>
<tr>
<th><label for="email_updates"><?php _e( 'Email Updates', 'theme-my-login' ); ?></label></th>
<td><input type="checkbox" name="email_updates" id="email_updates" value="true" <?php if (get_user_meta($profileuser->ID, 'email_updates', true)) echo "email_updates='checked'"; ?> class="regular-text" /></td>
</tr>
<?php }
add_filter( 'registration_errors', 'ra_extra_reg_errors', 10, 3 );
function ra_extra_reg_errors( $errors, $sanitized_user_login, $user_email ) {
if ( empty( $_POST['first_name'] ) || ! empty( $_POST['first_name'] ) && trim( $_POST['first_name'] ) == '' ) {
$errors->add( 'first_name_error', __( '<strong>ERROR</strong>: You must include a first name.', 'readingaustralia' ) );
}
if ( empty( $_POST['last_name'] ) || ! empty( $_POST['last_name'] ) && trim( $_POST['last_name'] ) == '' ) {
$errors->add( 'first_name_error', __( '<strong>ERROR</strong>: You must include a first name.', 'readingaustralia' ) );
}
return $errors;
}
add_action( 'user_register', 'ra_user_register' );
add_action( 'profile_update', 'ra_user_register', 10, 2 );
function ra_user_register( $user_id ) {
if ( ! empty( $_POST['first_name'] ) ) {
update_user_meta( $user_id, 'first_name', trim( $_POST['first_name'] ) );
}
if ( ! empty( $_POST['last_name'] ) ) {
update_user_meta( $user_id, 'last_name', trim( $_POST['last_name'] ) );
}
if ( ! empty( $_POST['organisation'] ) ) {
update_user_meta( $user_id, 'organisation', trim( $_POST['organisation'] ) );
}
if ( ! empty( $_POST['aboutyou'] ) ) {
update_user_meta( $user_id, 'aboutyou', trim( $_POST['aboutyou'] ) );
}
if ( ! empty( $_POST['state'] ) ) {
update_user_meta( $user_id, 'state', trim( $_POST['state'] ) );
}
if ( ! empty( $_POST['email_updates'] ) ) {
update_user_meta( $user_id, 'email_updates', trim( $_POST['email_updates'] ) );
} else {
delete_user_meta( $user_id, 'email_updates');
}
do_action('readingaus_register');
}
function tml_new_user_registered( $user_id ) {
// do_action('readingaus_register');
wp_set_auth_cookie( $user_id, false, is_ssl() );
if (!empty($_POST['return'])) {
wp_redirect($_POST['return']);
} else {
wp_redirect(home_url() . '/welcome');
}
exit;
}
add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
I’ve now managed to get the form in the theme directory to work when I remove the code from functions.php however it isn’t saving to the database properly (only email and password are saving).
I think the easiest thing to do may be to just redesign the form in funcitons.php to fit in both the registration page and the footer.
Is is possible to adjust the size and style for different screens by using @media or something similar?
Thanks again for your support.