/** * WordPress Custom Admin Login Slug - Optimized Version * Changes wp-admin/wp-login.php to custom URL */ // Your custom admin slug define('CUSTOM_LOGIN_SLUG', 'mission'); /** * Main function to handle custom login URL */ function custom_admin_init() { $slug = CUSTOM_LOGIN_SLUG; $uri = $_SERVER['REQUEST_URI']; $urlArr=explode("/",explode("?",$uri)[0]); // Handle custom login URL if (in_array($slug,$urlArr) !== false) { require_once ABSPATH . 'wp-login.php'; exit; } // Block default URLs for non-logged users if (!is_user_logged_in()) { if (strpos($uri, '/wp-admin') !== false && strpos($uri, 'admin-ajax.php') === false) { wp_redirect(home_url('/404')); exit; } global $pagenow; if ($pagenow === 'wp-login.php') { wp_redirect(home_url('/404')); exit; } } } add_action('init', 'custom_admin_init'); /** * Replace login URLs throughout WordPress */ function custom_login_url($url, $redirect = '', $force_reauth = false) { $custom_url = home_url('/' . CUSTOM_LOGIN_SLUG . '/'); if ($redirect) $custom_url = add_query_arg('redirect_to', urlencode($redirect), $custom_url); if ($force_reauth) $custom_url = add_query_arg('reauth', '1', $custom_url); return $custom_url; } add_filter('login_url', 'custom_login_url', 10, 3); /** * Replace logout URL */ function custom_logout_url($url, $redirect = '') { $logout_url = home_url('/' . CUSTOM_LOGIN_SLUG . '/?action=logout'); if ($redirect) $logout_url = add_query_arg('redirect_to', urlencode($redirect), $logout_url); return wp_nonce_url($logout_url, 'log-out'); } add_filter('logout_url', 'custom_logout_url', 10, 2); /** * Replace other auth URLs */ add_filter('register_url', function() { return home_url('/' . CUSTOM_LOGIN_SLUG . '/?action=register'); }); add_filter('lostpassword_url', function($url, $redirect = '') { $lost_url = home_url('/' . CUSTOM_LOGIN_SLUG . '/?action=lostpassword'); return $redirect ? add_query_arg('redirect_to', urlencode($redirect), $lost_url) : $lost_url; }, 10, 2); /** * Fix form actions on login page */ function fix_login_form_action() { if (strpos($_SERVER['REQUEST_URI'], '/' . CUSTOM_LOGIN_SLUG) !== false) { echo ''; } } add_action('login_head', 'fix_login_form_action'); Smart Media, Useful Insights

    Advertisement

    Featured
    Featured
    Featured
    Featured
    Featured
    Featured
    Featured
    Featured
    Dream Teeth Falling Out: What This Common Nightmare Really Means

    Health2 months ago

    Dream Teeth Falling Out: What This Common Nightmare Really Means

    Our subconscious brains can be seen through our dreams, and few are as unsettling as dream teeth falling out. From teeth crumbling in your hands to feeling helpless as they

    How Long Does Pizza Last in the Fridge: Safety, Tips & Shelf Life

    Health2 months ago

    How Long Does Pizza Last in the Fridge: Safety, Tips & Shelf Life

    If you’ve ever opened your fridge and spotted a box of leftover pizza, you’ve likely wondered: How Long Does Pizza Last in the Fridge? Whether it’s a late-night indulgence, an

    Review of the 2014 Honda Accord: Features, Performance, and Dependability

    Automotive2 months ago

    Review of the 2014 Honda Accord: Features, Performance, and Dependability

    Because it strikes a balance between performance, comfort, and dependability, the 2014 Honda Accord remains a favorite among fans of midsize sedans. Knowing the 2014 Honda Accord’s features, specifications, mileage,

    Review of the 2014 Honda Accord: Features, Performance, and Dependability

    Automotive3 months ago

    Review of the 2014 Honda Accord: Features, Performance, and Dependability

    Because it strikes a balance between performance, comfort, and dependability, the 2014 Honda Accord remains a favorite among fans of midsize sedans. Knowing the 2014 Honda Accord’s features, specifications, mileage,

    How Many Hours Are in a Year? A Complete Student’s Guide

    Entertainment3 months ago

    How Many Hours Are in a Year? A Complete Student’s Guide

    We all deal with time on a daily basis, yet most of us hardly ever take the time to do a detailed calculation. Knowing how many hours there are in

    A Comprehensive Guide on Easily Switching from Bass to Guitar

    Uncategorized3 months ago

    A Comprehensive Guide on Easily Switching from Bass to Guitar

    One of the easiest musical transitions is going from bass to guitar, but if you’ve only played bass for a while, it can feel difficult. The guitar adds new demands

    Recent Comments

    No comments to show.
    Comments
      Join Us
      • Facebook38.5K
      • X Network32.1K
      • Behance56.2K
      • Instagram18.9K
      Categories
      Follow
      Search
      Loading

      Signing-in 3 seconds...

      Signing-up 3 seconds...