How to redirect a user to a specific page only at the first login of the wordpress site?

Asked

Viewed 138 times

0

I include right in the table some users wp_users, only with the ID, USER_LOGIN, USER_PASS, USER_NICENAME AND DISPLAY_NAME.

Getting like this, for example:

INSERT INTO wp_users (ID, user_login, user_pass, user_nicename, user_email, 
user_url, user_registered, user_activation_key, user_status, display_name) 
VALUES
(1500, ‘steoliv’, ‘65442334hio’,’steoliv’, ”, ”,’2018-01-09 13:01:00′, ”, 0, 
‘Stefany’);

I would like the first access, made by the username and password I created, redirect the user to a page , that I have created (site/edit-registration) and update the data with the missing information, such as email. Have some plugin or some code that is possible to do what I wish?

  • I believe you need a flag to know this; try adding another field as first_login user and so Voce can check whether or not it is the first login; when you register the field is set to "1" and after editing the data on the page Voce wants to be set to "0".

  • Ta, but there you are telling me to check. I need something to help me even if it is to do this every time the user logs in. If I find one that already does that’s halfway done.

1 answer

0

You can use a flag to know whether or not this is the first time a user has logged in to your platform. Add this flag to your database and whenever the user logs in you test the Fleg. After testing if the user and password are correct you test the flag

if(result['flag'] == 0){
    // Atualiza a colona da flag
    $query = "UPDATE wp_users SET flag = 1 WHERE usuario = $usuario";
    mysqli_query($con,$query);
    // Faz o redirecionamento para a página de editar cadastro
    header("location: http://minhaurl/site/editar-cadastro");
}else{
    header("location: http://minhaurl/site/outra-area");
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.