V
V
Vova512022-04-18 01:03:09
WordPress
Vova51, 2022-04-18 01:03:09

How to make sure that after registering a person on the site, the registration menu (WordPress) disappears?

I need a person after registering on the site could not get to the registration or login form

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
goshaLoonny, 2022-04-18
@Vova51

The is_user_logged_in() function checks if the user is logged in. If you are automatically authorized after registration, then you should use the condition

<?php if (!is_user_logged_in()): ?>

<form> Ваша форма </form>

<?php endif; ?>

There is also a hook register_new_user which is triggered after registering a new user. You can write a variable to the session and check it where you show the form
add_action( 'register_new_user', 'action_register_new_user' );
function action_register_new_user( $user_id ){
  if (!session_id()) session_start();

  $_SESSION['hide_auth_form'] = true;
}

And checking where the form is
<?php 
if (!session_id()) session_start();
if (isset($_SESSION['hide_auth_form']) and $_SESSION['hide_auth_form']):
?>

<form> Ваша форма </form>

<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question