| @@ -20,14 +20,14 @@ | ||
| 20 | 20 | if ( is_user_logged_in() ) { |
| 21 | 21 | return '<div class="frmx-auth-logged-in">' . esc_html__( 'You are already logged in.', 'forumax' ) . '</div>'; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - // One login form per page — same shortcode on another page still works. | |
| 25 | - static $frmx_login_form_rendered = false; | |
| 26 | - if ( $frmx_login_form_rendered ) { | |
| 27 | - return ''; | |
| 28 | - } | |
| 29 | - $frmx_login_form_rendered = true; | |
| 24 | + // Same shortcode is used on several spots of one page (reply prompt, topic | |
| 25 | + // prompt, subscribe modal, page content). Each instance needs its own IDs | |
| 26 | + // so a later form is not dropped and tabs/labels stay wired to that form. | |
| 27 | + static $frmx_login_form_instance = 0; | |
| 28 | + $frmx_login_form_instance++; | |
| 29 | + $uid = 'frmx-auth-' . $frmx_login_form_instance; | |
| 30 | 30 | |
| 31 | 31 | // Extract shortcode attributes with defaults. |
| 32 | 32 | $atts = shortcode_atts( array( |
| 33 | 33 | 'redirect' => '', |
| @@ -36,9 +36,9 @@ | ||
| 36 | 36 | // Set redirect URL. |
| 37 | 37 | $redirect_url = ! empty( $atts['redirect'] ) ? $atts['redirect'] : get_permalink(); |
| 38 | 38 | |
| 39 | 39 | $can_register = get_option( 'users_can_register' ); |
| 40 | - $wrapper_id = 'frmx-auth-tabs'; | |
| 40 | + $wrapper_id = $uid; | |
| 41 | 41 | |
| 42 | 42 | ob_start(); |
| 43 | 43 | ?> |
| 44 | 44 | <div class="frmx-auth-tabs" id="<?php echo esc_attr( $wrapper_id ); ?>"> |
| @@ -62,9 +62,13 @@ | ||
| 62 | 62 | 'label_username' => esc_html__( 'Username or Email', 'forumax' ), |
| 63 | 63 | 'label_password' => esc_html__( 'Password', 'forumax' ), |
| 64 | 64 | 'label_remember' => esc_html__( 'Remember Me', 'forumax' ), |
| 65 | 65 | 'label_log_in' => esc_html__( 'Sign In', 'forumax' ), |
| 66 | - 'form_id' => 'forumax_login_form', | |
| 66 | + 'form_id' => $uid . '-login', | |
| 67 | + 'id_username' => $uid . '-user', | |
| 68 | + 'id_password' => $uid . '-pass', | |
| 69 | + 'id_remember' => $uid . '-remember', | |
| 70 | + 'id_submit' => $uid . '-submit', | |
| 67 | 71 | 'remember' => true, |
| 68 | 72 | 'echo' => false, |
| 69 | 73 | ) ); |
| 70 | 74 | |
| @@ -109,25 +113,25 @@ | ||
| 109 | 113 | <input type="hidden" name="action" value="forumax_register" /> |
| 110 | 114 | <input type="hidden" name="redirect_to" value="<?php echo esc_url( $redirect_url ); ?>" /> |
| 111 | 115 | |
| 112 | 116 | <div class="frmx-auth-field"> |
| 113 | - <label for="frmx_reg_user_login"><?php esc_html_e( 'Username', 'forumax' ); ?></label> | |
| 114 | - <input type="text" name="user_login" id="frmx_reg_user_login" placeholder="<?php esc_attr_e( 'Username', 'forumax' ); ?>" autocomplete="username" required /> | |
| 117 | + <label for="<?php echo esc_attr( $uid ); ?>-reg-login"><?php esc_html_e( 'Username', 'forumax' ); ?></label> | |
| 118 | + <input type="text" name="user_login" id="<?php echo esc_attr( $uid ); ?>-reg-login" placeholder="<?php esc_attr_e( 'Username', 'forumax' ); ?>" autocomplete="username" required /> | |
| 115 | 119 | </div> |
| 116 | 120 | |
| 117 | 121 | <div class="frmx-auth-field"> |
| 118 | - <label for="frmx_reg_user_email"><?php esc_html_e( 'Email', 'forumax' ); ?></label> | |
| 119 | - <input type="email" name="user_email" id="frmx_reg_user_email" placeholder="<?php esc_attr_e( 'Email', 'forumax' ); ?>" autocomplete="email" required /> | |
| 122 | + <label for="<?php echo esc_attr( $uid ); ?>-reg-email"><?php esc_html_e( 'Email', 'forumax' ); ?></label> | |
| 123 | + <input type="email" name="user_email" id="<?php echo esc_attr( $uid ); ?>-reg-email" placeholder="<?php esc_attr_e( 'Email', 'forumax' ); ?>" autocomplete="email" required /> | |
| 120 | 124 | </div> |
| 121 | 125 | |
| 122 | 126 | <div class="frmx-auth-field"> |
| 123 | - <label for="frmx_reg_user_pass"><?php esc_html_e( 'Password', 'forumax' ); ?></label> | |
| 124 | - <input type="password" name="user_pass" id="frmx_reg_user_pass" placeholder="<?php esc_attr_e( 'Password', 'forumax' ); ?>" autocomplete="new-password" required /> | |
| 127 | + <label for="<?php echo esc_attr( $uid ); ?>-reg-pass"><?php esc_html_e( 'Password', 'forumax' ); ?></label> | |
| 128 | + <input type="password" name="user_pass" id="<?php echo esc_attr( $uid ); ?>-reg-pass" placeholder="<?php esc_attr_e( 'Password', 'forumax' ); ?>" autocomplete="new-password" required /> | |
| 125 | 129 | </div> |
| 126 | 130 | |
| 127 | 131 | <div class="frmx-auth-field"> |
| 128 | - <label for="frmx_reg_user_pass_confirm"><?php esc_html_e( 'Confirm Password', 'forumax' ); ?></label> | |
| 129 | - <input type="password" name="user_pass_confirm" id="frmx_reg_user_pass_confirm" placeholder="<?php esc_attr_e( 'Confirm Password', 'forumax' ); ?>" autocomplete="new-password" required /> | |
| 132 | + <label for="<?php echo esc_attr( $uid ); ?>-reg-pass-confirm"><?php esc_html_e( 'Confirm Password', 'forumax' ); ?></label> | |
| 133 | + <input type="password" name="user_pass_confirm" id="<?php echo esc_attr( $uid ); ?>-reg-pass-confirm" placeholder="<?php esc_attr_e( 'Confirm Password', 'forumax' ); ?>" autocomplete="new-password" required /> | |
| 130 | 134 | </div> |
| 131 | 135 | |
| 132 | 136 | <?php |
| 133 | 137 | /** |
| @@ -139,9 +143,9 @@ | ||
| 139 | 143 | do_action( 'register_form' ); |
| 140 | 144 | ?> |
| 141 | 145 | |
| 142 | 146 | <div class="frmx-auth-submit"> |
| 143 | - <button type="submit" id="frmx-register-submit" name="wp-submit" class="button submit fill-brand"> | |
| 147 | + <button type="submit" id="<?php echo esc_attr( $uid ); ?>-register" name="wp-submit" class="button submit fill-brand"> | |
| 144 | 148 | <?php esc_html_e( 'Register', 'forumax' ); ?> |
| 145 | 149 | </button> |
| 146 | 150 | </div> |
| 147 | 151 | |