Skip to main content

@ WP Experts - Best Way to Disable "wp-admin" URL?

I mean, I know there are plugins and all, but I'm trying to learn the best way from people in this community! TIA! <3 πŸ™Œ

@ WP Experts - Best Way to Disable "wp-admin" URL?

Shahjahan Jewel

if you use FluentAuth plugin you can disable /wp-admin access by selected user roles.

The GS

Shahjahan JewelΒ Thanks so much, Shahjahan, for your response! Sorry, I'm not sure if we're talking about the same thing. So, please allow me to explain:

I have already enabled this setting in FluentAuth: "Disable admin bar andΒ /wp-admin/Β access for selected user roles." β€” and selected all three available roles there: Subscriber, Customer, and Contributors.

But when I manually type my website URL + "wp-admin" (example.com/wp-admin) in Incognito, it opens the WP login page.

What I'm trying to achieve is that "example.com/wp-admin" must not open a WP login page at all, and redirect the user to my official community login page. I tried checking all the FluentAuth settings for this. But couldn't achieve it. Sorry if I'm missing out on something! πŸ₯ΊπŸ™

Shahjahan Jewel

The GSΒ you can use this php snippet:

add_action('login_form_login', function () {
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        return;
    }

    wp_safe_redirect(home_url('/community/')); // change
    exit;
});

The GS

Shahjahan Jewel Whoa!!!! It did work just as I intended. 🀩

You're a legend, sir! I appreciate you! πŸ€—

Thank you so much for always being there for the community. Much much appreciated! πŸ’šβœ¨πŸ™