After researching and looking up the WordPress Codex, this is the code that I have used to authenticate..
I hope this helpful to all friends .it’s working fine for me 🙂
$creds = array(
'user_login' => $username,
'user_password' => $userpassword,
'remember' => true
);
if(!empty($username) && !empty($userpassword)) {
if(!username_exists($username)) {
$userdata = array(
'user_login' => $username,
'user_email' => $useremail,
'user_pass' => $userpassword,
'role' => 'customer'
);
$user_id = wp_insert_user( $userdata ) ;
$user = wp_signon( $creds, false );
wp_set_current_user($user->ID,$username);
wp_set_auth_cookie($user->ID, true, false );
wp_redirect(site_url());
}
Related Posts:
- Change GitHub Account username
- Google OAuth 2 authorization – Error: redirect_uri_mismatch
- What are the main differences between JWT and OAuth authentication?
- How to use OAuth authentication with REST API via CURL commands?
- How to validate a user from ouside wordpress/php?
- Override user authentication with external credentials
- JWT authentication with WP – Approach
- why does WordPress need two cookies for auth/login
- Extend WordPress (4.x) session and nonce
- How to use WordPress authentication on non-WordPress page?
- How does ifttt.com authenticate a supplied WordPress account
- Storing Dropbox Authentication?
- WordPress as a OAuth Provider
- Authentication for wordpress website
- How to leverage authentication outside of WordPress?
- How do I execute a wp_remote_get call using NTLM authentication?
- Outgoing proxy connection problem
- WordPress SSO with MemberPress
- Authenticated request to WP REST API V2 returning 403 error on /users/me [closed]
- Set authentication cookies to be shorter but then extend with every page load
- WordPress asking for FTP details when installing plugins
- How to password protect media library files (PDF)?
- How to use Azure AD for authentication?
- implement authentication and authorization to user
- for a role-protected page, programmatically login user and load page
- guest authentication
- wordpress 3.9 remote token auth
- How to set up Shibboleth authentication for a MU site
- Login after “Read More” then return to article
- How to make WordPress use authentication from Parent Site
- auto logout user when user logout on one of the opened tab
- How can I have authenticated WordPress users automatically sign into Moodle?
- Requiring Authentication for Parts of WordPress Site
- WooCommerce OAuth 1.0 + JWT authentication with JS/React
- Authenticating users with usermeta fields
- Getting Authentication required popup
- How can LDAP/Active Directory be integrated in WordPress?
- Authenticate Subdomain
- How to create new users with JWT Auth Plugin?
- Mirgrating a user at signon
- Automate WordPress Login
- Application to Website authentication
- How to authenticate using JWT by ajax?
- Open authenticed WordPress page from mobile app
- Access to customer profile with pin code
- WP link for reset password is not received
- How to make an other web app can login with wordpress authentication?
- How to add additional factor to wordpress authentication
- Adding a “Sign In/My Account” link to an external app
- Check if user is logged in, inside php file in template directory
- Connect my WordPress site users to my public site account without showing my public site credentials
- WordPress Multisite and site speed and scaleability
- Blocking the direct access to images in the upload folder WordPress
- Can you pass user/pass for HTTP Basic Authentication in URL parameters?
- What is the difference between authentication and authorization?
- wp_signon by user’s login by their particular role
- Git push results in “Authentication Failed”
- Google OAuth 2 authorization – Error: redirect_uri_mismatch
- Automatic WordPress Login of Logged In ClickFunnels User
- How to: Make JWT-authenticated requests to the WordPress API
- custom XMLRPC method plus authentication of user & WooCommerce order
- Ajax for non-logged-in users
- WordPress Rest API: How do we validate with our custom API key?
- WordPress REST API call generates nonce twice on every call
- authentication issue with rest api – rest_cannot_create
- Utilize WordPress Authentication Only
- How do I authenticate WP users from a chrome extension?
- External system integration with wordpress
- My custom page template with is_user_logged_in() does not detect that I’m logged in
- how to send Ajax request in wordpress backend
- How do I get WordPress login to ignore the password input if a particular username is used?
- Hooking into ‘authenticate’ causes login to submit on page load
- Authentication with the Rest API when using an External Application
- Calling an API to do authentication / user login
- WordPress authentication cookie and ajax calls
- OAuth 2 and saving the authenticated user
- Continuous Login Sessions For Super Admins Across Multi-Site Network of Sites
- How to set a cookie for logged in users to md5($user->ID . “my_secret”)?
- New user form rejected because “passwords don’t match”—but there’s only one password field
- REST API: wp_get_current_user not working on second call
- Detect if authentication is set to “remember” a user being logged on
- Where is function to prevents non logged users access wp-admin?
- I want login using email not username wordpress front end
- Login redirect shows white page in firefox
- Need to use WordPress page as authentication for different service
- wp_nonce vs jwt
- Force REST API Authentication for each request method
- prevent anonymous access to WordPress site (non-admin site)
- Changing auth_redirect() page
- How can I upload and password protect Javadocs in WordPress?
- How can cookie/session authentication be used in wp-json fetch request?
- Users are required to login to my site. How define user.member boolean, its permissions, and conditionally display/handle behavior based on it
- WordPress Child Theme Template auth_redirect wrapper
- Why ‘Authorization Required’ is coming on wordpress login
- Handle POST request sent from an external site for login?
- WordPress Site login problem with facebook, twitter and other social media
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- How to track all users logged into a site?
- SSH use only my password, Ignore my ssh key, don’t prompt me for a passphrase
- How to delete cached temporarily credentials for a network share on a Windows machine without rebooting or logging off [duplicate]