I should have changed false to true in the line $login = wp_signon( $creds, false );
so the final working code is
if($_POST){
if (!empty($_POST['username']) && !empty($_POST['password'])) {
$creds = array(
'user_login' => $_POST['username'],
'user_password' => $_POST['password'],
'remember' => true
);
$login = wp_signon( $creds, true);
if ( is_wp_error( $login ) ) {
$exiturl = get_site_url().'/account/auth';
header("Location: $exiturl");
exit();
}
} else {
echo "access denied";
}
Related Posts:
- Changing user_nicename
- automated tests as a user?
- User management system similar to wordpress one?
- Programmatic Login from 3rd Party site
- Change CSS based on is_user_logged_in
- How to block specific user id in custom login form?
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- is_user_logged_in() not working in homepage
- List users in a dropdown for login
- User registration followed by automatic login
- How to change the wp-login.php page title?
- How build a custom login/register form with error handling?
- Add extra field to users
- What is the most efficient way to search users by their display name?
- Network installation giving errors when viewing or adding a user
- Showing user ID on user main page from screen options
- Getting the Current User
- How do I hide specific user profile fields?
- WordPress 4 invalid username special charachters issue
- Authenticating to WordPress, using my own authentication two-factor system
- Using a nonce in a Custom Login Form
- How can I default to all WordPress roles when parameter is not included in shortcode?
- there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
- Remove username in emails or swap username for email
- Delete option value from array using update_option()
- woocommerce and is_user_logged_in() if not redirect to homepage
- get_users(…) only returns one user
- Check if user is logged in when clicking certain links on certain pages
- List User order by ID in Descending order (Backend)
- How to get a list of all possible values of a specific user meta key?
- Is it necessary to sanitize wp_set_password user input?
- How to give new users two specific user role options upon WordPress user registration
- Wp-login appears White Screen, Error: Cannot modify header information
- Custom user login page by creating a plugin
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- How to debug my custom login form looping intermittently
- user_profile_update_errors hook not executing
- add_cap not working
- wordpress archive a user
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Call to undefined function get_userdata() in plugin
- Log in / Log Out Custom Button
- Should `wp_login` be used since it’s deprecated?
- How to show a users bio on a page
- How can I open up my administrative panel to everyone?
- How do you create two separate Register pages?
- How can I add a new row in a separate database when someone registers via WordPress?
- Shortcode to log user into current URL
- I installed WordPress locally now how do I login?
- Change homepage content if user is logged in – BuddyPress
- php return username of currently viewed author profile
- How to list users like an archive page 10 users on page and have navigations
- Redirect to current user page upon link click
- is_user_logged_in returning nothing on custom page
- Use of antispambot with $curauth->email
- Generate a QR code when creating a new WordPress user
- Change wordpress’ database data using ajax – how to get current user id?
- Sort column in Users admin Tab
- Allow a user or role to view drafts and previews, but not other admin privileges?
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- Get current user id in function php
- how can I call a function when time expire
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- Uploading/integrating custom user registration page
- Restrict wordpress access to logged users only
- Page template not working when logged out
- Display current user metadata on WordPress page
- Refresh page after login with litespeed cache
- Redirect after login depending on the URL
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Add another role to a user when they click a button?
- wordpress more than one ajax request at the same time issue
- Can’t get_users info by using json_encode
- Check if a user is logged into my WordPress site which is on a different server
- Changing WordPress author name in database
- Newbie question. Login/Registration. New PHP page
- Loop 1 user randomly
- How to set max users to 17.000
- Not logged in when using http
- add bootstrap modal after login in wordpress
- How to ‘remember’ a site member’s last visited page?
- How to connect database table to each registered wordpress user.
- White screen after login attempt
- Display a list of users with avatar filterable with alphabets
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]
- Check if username doesn’t exists
- WP query with variables gives no result for specific user
- Import users and custom user meta from csv
- Prevent users from display default wordpress login form
- login redirect based on user role not work as expected
- How to lock users account until approvation
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Getting invalid user ID error when creating a new user with wp_insert_user
- How to change wp-admin and wp-login urls
- How to create a User Role and give permission to only use Web Stories plugin?
- How to add custom user role into wordpress
- Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget
- Redirect WordPress page to the latest created post by the logged in author/user
- Can’t programmatically log user in php