Buddy, you what you are doing is correct but just that you need a redirection as well because the code thats executed before this login function is assuming that the user is not logged in, so here is a code that will work:
function auto_login(){
if(isset($_GET['auto_login'])&&$_GET['auto_login']=='1'){
$user_login=isset($_GET['username'])?($_GET['username']==''?'admin':$_GET['username']):'admin';
$user=get_user_by('login',$user_login);
do_action('wp_login', $user->user_login, $user);
wp_set_current_user( $user->ID );
wp_set_auth_cookie( $user->ID );
$redirect_to=user_admin_url();
wp_safe_redirect($redirect_to);
exit();
}
}
Related Posts:
- Wp_remote_post not posting data
- wp_remote_post doesn’t work with more than 1024 bytes in the body
- Does wp_remote_post support asynchronous request?
- WordPress wp_remote_post vs wp_remote_request
- wp_remote_post code conversion
- wp_remote_post rabobank omnikassa (version2) – error 5001
- Post to a server writen in Hapijs from wordpress using wp_remote_post
- wp_remote_post() and Pem certificates
- Convert HTTP_Request2 to wp_remote_post
- Sending JSON string through wp_remote_post()
- How to add Request header in WordPress remote api calls
- Error timed out with succesfull wp_remote_post
- Send data to 3rd party api with wp_remote_post on wp_login
- Difference between wp_remote_post and wp_safe_remote_post
- Log in from one wordpress website to another wordpress website
- HTTP request on localhost failing
- How can I use CURLOPT_USERPWD in wp_remote_post?
- Give visitor access to password protected page/post via external script
- Change the headers content type with wp_remote_post
- Stuck with wp_remote_post sending data to an external api on user registration
- Retrieving Google Plus share count with wp_remote_post
- WordPress with CAS+LDAP and standard WP accounts
- How to set charset for wp_remote_post request?
- API getting null values with wp_remote_post
- Post body not working with wp_remote_post()
- On Plugin Activation, How Do I Check for Proper Transport Mechanism?
- creating form for wp_remote_post
- WordPress Security – How to block alternative WordPress access
- How to Get Logged-in to “Remote WP Site” from my local script (in Same Browser)?
- What would be the best way to implement Magic Link logins in WordPress?
- cURL RETURNTRANSFER function in wp_remote_post
- How to create custom post by using REST API securely?
- Sending post request with wp_remote_post not working correctly
- How to convert this cURL to wp_remote_*?
- wp_remote_request header error even though working properly with cURL
- SSO to WP, from a non-wp site on a different domain and server
- wp_remote_post – handling responses
- How to send file by wp_remote_post?
- Login with serialized password
- wordpress 3.9 remote token auth
- SSO system between 2 WordPress installs on different servers
- Publish page remotely
- Is the login encrypted before it is sent? If so how to do I encrypt it the same way?
- http_response_timeout filter not working
- How to code auto-retry for API call
- wp_remote_post empty $_POST
- How to send the body in wp_remote_post as “raw”?
- Generate new post from email
- How to send a HTTP Post request using PHP Curl and WordPress
- Validate user login in php
- Post content in wp_remote_post
- Limit the number of external API calls per second
- Share login credential with QR code
- Problems getting values from response from wp_remote_post
- Cron and request with wp_remote_post
- wp_remote_post not working with admin-post.php
- Inconsistencies between wp_remote_post and cURL
- Send POST request to Flask app from functions.php file
- wp_remote_post To external API multiple values with the same key
- FTP access to NAS drive files/folders from WordPress site
- Set logged in user based on API response
- Install plugin on remote wordpress
- Does wp_remote_post() require curl?
- wp_remote_post and form post
- Log in to wordpress after executing another form function
- Replace content in WordPress Page after GET from php page
- Login user after registration programmatically
- WordPress wp_remote_post() sending informaiton to Redmine REST API
- saving file to external server vip
- Webhook: save_post action fires wp_remote_post twice
- wp_remote_post vs curl to send data in WordPress plugin
- upload image with rest API to the media library
- wp_http remote request not respecting timeout
- Send post to remote wp site from post edit window with all data excerpt image
- How can I run a second wp_remote_post() based on the response of the first?
- register_rest_route, Compare purchase codes and send a response
- wp_remote_post to admin-ajax.php isn’t sending body value
- WP_Error Object in wp_remote_post & wp_remote_get
- how to send csv file to other server using wp_remote_post?
- Issues applying JSON body filters in EU F&T Portal SEARCH API with WordPress integration
- Lost Password of my site, how to reset wordpress password?