Здраствуйте, мне нужно чтобы когда пользователь вводил определений почтовый домен, ему открывалось содержимое защищенной страницы WordPress, страница сделана на Elementor Pro, у меня есть код который делает валидацию почт но не показывает содержимое страницы после успешного ввода, можно ли эго улучшить?
Сайт пример
https://nikolaydmytrotsa.com/home/add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
global $post;
if (isset($_POST['email'])) {$email = $_POST['email'];} else {$email = '';}
$sanitized_email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (preg_match("/^(?:[a-z0-9]+(?:[-_.]?[a-z0-9]+)?@[test.-]+.[com]{2,5})$/i", $sanitized_email) OR preg_match("/^(?:[a-z0-9]+(?:[-_.]?[a-z0-9]+)?@[test2.-]+.[com]{2,5})$/i", $sanitized_email) ) {
echo \Elementor\plugin::instance()->frontend->get_builder_content( $template_id, true );
echo "E-mail адрес <font color=green><b>" . $sanitized_email . "</b></font> specified correctly<br>\n";
} else {
echo "E-mail адрес <font color=red><b>" . $sanitized_email . "</b></font> specified incorrectly<br>\n";
}
$o = '<form action="" role="search" method="post">' . __( "This post is password protected. To view it, enter your email below" ) . '>
<input type="text" name="email" placeholder="enter email">
<input class="enter" type="submit" value="Enter!">
</form>';
return $o;
}