Last active
July 21, 2021 06:52
-
-
Save selul/2f5f76d423f9d44f7b5a927e17001c28 to your computer and use it in GitHub Desktop.
Remove login on wordpress site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Remove login. | |
Description: Plugin that removes login WordPress, useful on testing environments. Should never be used on production. | |
Author: Marius Cristea | |
Version: 0.0.1 | |
*/ | |
add_action( 'after_setup_theme', function () { | |
if ( ! is_user_logged_in() ) { | |
$autologin_user = wp_signon( | |
[ | |
'user_login' => 'admin', | |
'user_password' => 'admin', | |
'remember' => true | |
], | |
false | |
); | |
if ( ! is_wp_error( $autologin_user ) ) { | |
header( 'Location: wp-admin' ); | |
} | |
} | |
} ); | |
add_filter( 'rest_authentication_errors', function () { | |
wp_set_current_user( 1 ); | |
}, 101 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment