' . esc_html__( 'You are already logged in.', 'forumax' ) . '';
}
// Extract shortcode attributes with defaults.
$atts = shortcode_atts( array(
'redirect' => '',
), $atts );
// Set redirect URL.
$redirect_url = ! empty( $atts['redirect'] ) ? $atts['redirect'] : get_permalink();
$can_register = get_option( 'users_can_register' );
$wrapper_id = uniqid( 'frmx-auth-tabs-' );
ob_start();
?>
$redirect_url,
'label_username' => esc_html__( 'Username or Email', 'forumax' ),
'label_password' => esc_html__( 'Password', 'forumax' ),
'label_remember' => esc_html__( 'Remember Me', 'forumax' ),
'label_log_in' => esc_html__( 'Sign In', 'forumax' ),
'form_id' => 'forumax_login_form',
'remember' => true,
'echo' => false,
) );
// Add placeholders to core login form fields.
$username_placeholder = esc_attr__( 'Username or Email', 'forumax' );
$password_placeholder = esc_attr__( 'Password', 'forumax' );
$form_html = preg_replace(
'/(]*\bplaceholder=)[^>]*\bname=["\']log["\'][^>]*)(\/?\s*>)/i',
'$1 placeholder="' . $username_placeholder . '"$2',
$form_html
);
$form_html = preg_replace(
'/(]*\bplaceholder=)[^>]*\bname=["\']pwd["\'][^>]*)(\/?\s*>)/i',
'$1 placeholder="' . $password_placeholder . '"$2',
$form_html
);
echo $form_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
get_error_code(), $referrer ) );
exit;
}
// Create the user.
$user_id = wp_create_user( $user_login, $user_pass, $user_email );
if ( is_wp_error( $user_id ) ) {
$error_code = $user_id->get_error_code();
wp_safe_redirect( add_query_arg( 'reg_error', $error_code, $referrer ) );
exit;
}
// Fire standard WordPress registration action.
do_action( 'user_register', $user_id );
// Auto-login the new user.
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id, true );
wp_safe_redirect( $redirect );
exit;
}
add_action( 'admin_post_nopriv_forumax_register', 'forumax_handle_registration' );
add_action( 'admin_post_forumax_register', 'forumax_handle_registration' );