Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter pstockley

    (@pstockley)

    Also I thought I might add that I’ve tried adding the form to pages using shortcodes too:

    [theme-my-login default_action=”register” register_template=”register-form-f”]

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Try register_template="register-form-f.php".

    Thread Starter pstockley

    (@pstockley)

    Thanks for your suggestion, Jeff.

    But it appears that it still won’t call the file and that it is still calling the form from the functions.php file.

    I tried removing the form from functions.php entirely and calling register-form.php instead and it still won’t work – it says ‘Register’ on the page but the form is not appearing below it.

    I’m running out of ideas quickly here – unless there is an issue with my code (although it’s a duplicate form from the one in functions.php which was working fine).

    What is your opinion about using functions.php instead of adding the form to the directory? Is there any advantage?

    Thanks again

    @jeff Farthing please check thi & reply.

    Awaiting your response.

    Regards,

    Thread Starter pstockley

    (@pstockley)

    ^why

    Plugin Author Jeff Farthing

    (@jfarthing84)

    What is the code in functions.php?

    Thread Starter pstockley

    (@pstockley)

    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.

    Thread Starter pstockley

    (@pstockley)

    I’ve scrapped the alternate form and am now just working on making one form to fit all sizes.

    Thanks for trying though!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Multiple registration forms for different parts of the site’ is closed to new replies.