Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: login automagically if the plugin is installed #1

Open
vinkla opened this issue Apr 13, 2023 · 0 comments
Open

Feature request: login automagically if the plugin is installed #1

vinkla opened this issue Apr 13, 2023 · 0 comments

Comments

@vinkla
Copy link

vinkla commented Apr 13, 2023

I would like to propose two ideas for improving the plugin:

1. Enable super admin login on local environments when the plugin is installed.

It would be beneficial to allow users to log in as a super admin in a local environment when the plugin is installed. Here is a code snippet demonstrating this concept:

$id = 1;

if (
    wp_get_environment_type() !== 'local' || // if not local
    is_user_logged_in() || // if user is already logged in
    is_admin() === false || // if not admin
    is_super_admin($id) === false // if user is not super admin
) {
    return;
}

$user = get_user_by('id', $id);
$login = $user->data->user_login;

wp_set_current_user($id, $login);
wp_set_auth_cookie($id, true);
do_action('wp_login', $login, $user);

if (isset($_SERVER['REQUEST_URI'])) {
    wp_safe_redirect($_SERVER['REQUEST_URI']);
    exit;
}

2. Implement a constant for automatic super admin login in local environments.

As an alternative, introducing a constant that enables automatic super admin login in local environments when set to true could be advantageous:

AUTOMATIC_LOGIN=true

One of these enhancements would provide additional flexibility and ease of use for developers working with the plugin in their local environments. Please let me know your thoughts on these suggestions. I prefer the first one 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant