• Resolved whoaloic

    (@whoaloic)


    Hello,
    I use echo do_shortcode( ‘ [wppb-login] ‘ ); and echo do_shortcode( ‘ [wppb-register] ‘ in a template.
    In my template I have the login form and a button to display the registration form. When the registration form is shwn, there is a button to display the login form.
    Please see this page to see wha I mean: http://extranet.show-room-deco.fr/compte/

    When the user submits the registration form with errors, the login form is shown again but he has no idea what errors he has to correct. He has to click again on the button to display the registration form.

    I would like to display the error message in a template (above div that display both forms) to alway see error message.

    Is there a do_action or a snippet?

    Any idea would be really appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Georgian Cocora

    (@raster02)

    Hello there,

    You cannot really move the errors around, only if you reconstruct them. There is the wppb_test_required_form_values() function available, which you can make us of to know if what the user entered is fine or not.

    You should look to somehow show the Registration form on form submission redirect. Maybe look for the $_POST request when the page loads ?

    What code do you use to switch between the Login/Register forms and show the Login one by default ?

    Regards.

    Thread Starter whoaloic

    (@whoaloic)

    I use this code:

    add_shortcode ('login_reg_forms', 'add_login_reg_forms');
    
    function add_login_reg_forms() {
    		
    	ob_start(); ?>
    	<div class="gbtr_login_register_wrapper">
            
            <?php wppb_test_required_form_values();
            ?>            
        <div class="gbtr_login_register_slider" >    
                  
    		<div class='gbtr_login_register_slide_1'>
    
                <h2><?php _e( 'Login', 'wordpress' ); ?></h2>
        
                <?php echo do_shortcode( ' [wppb-login] ' ); ?>
                
                <?php if ( !is_user_logged_in() ) { ?>
                <p class="lost_password">
            <a href="<?php echo get_page_link(358); ?>">Lost password</a>
    </p>
    	<?php } ?>
            </div>
    
        
            <div class='gbtr_login_register_slide_2'>
    
                <h2><?php _e( 'Register', 'wordpress' ); ?></h2>
        
                <?php echo do_shortcode( ' [wppb-register] ' ); ?>
            </div>
            
    
    	</div>
    
    </div>
    
    <div class="gbtr_login_register_switch">
        <div class="gbtr_login_register_label_slider">
            
            
            
            <div class="gbtr_login_register_reg">
            	<h2><?php _e('Register', 'wordpress'); ?></h2>
                <?php _e( $theretailer_theme_options['registration_content'], 'woocommerce' ); ?>
                <input type="submit" class="button" name="create_account" value="<?php _e('Register', 'wordpress'); ?>">
            </div>
            <div class="gbtr_login_register_log">
            	<h2><?php _e('Login', 'wordpress'); ?></h2>
                <?php _e( $theretailer_theme_options['login_content'], 'wordpress' ); ?>
                <input type="submit" class="button" name="create_account" value="<?php _e('Login', 'wordpress'); ?>">
            </div>
        </div>
    </div>
    
    <div class="clr"></div>
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    jQuery(document).ready(function($) {
    	 $('.gbtr_login_register_slider').animate({
    		left: '0',
    	 }, 0, function() {
    		// Animation complete.
    	 });
    	 
    	 
    	 $('.gbtr_login_register_label_slider').animate({
    		top: '0',
    	 }, 0, function() {
    		// Animation complete.
    	 });
    	 
    });
    //--><!]]>
    </script>
    <?php return ob_get_clean();
    }
    • This reply was modified 9 years, 3 months ago by whoaloic.
    • This reply was modified 9 years, 3 months ago by whoaloic.
    • This reply was modified 9 years, 3 months ago by whoaloic.
    Plugin Author Georgian Cocora

    (@raster02)

    Hello there,

    Apologies for the late response.

    I am not sure what makes the Login form display first in the code that you provided, but if you could do a conditional over that part like this:

    if (isset($_POST) && $_POST['action'] == 'register') {
     //display register form
    }
    else {
     //display login form
    }

    Your users will be able to see the form errors.

    Regards.

    Thread Starter whoaloic

    (@whoaloic)

    Hello,
    I edit a WooCommerce account page that show both registration and login forms.
    At first, the login form is shown and the registration form is hidden with CSS.
    When the user clicks on the button “create an account”, the registration form is shown and the login form is hidden (with an animate jquery function).
    If the user made a mistake when submitting form, he gets a message above div that includes both forms. Please see WooCommerce site http://shop.show-room-deco.fr/mon-compte/
    For this site: http://extranet.show-room-deco.fr/compte/, I only need to print Profile Builder messages and errors instead of WooCommerce message errors.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Display error message in a template’ is closed to new replies.