OhhMuaOhhMua
  • Home
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Tools
    • veo3 prompt generator
  • Our Team
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
Reading: How to Change WordPress Login URL Without Plugins (100% Success)
Notification Show More
OhhMuaOhhMua
  • WordPress
  • Entry-level Builds
  • High-end Builds
  • Mid-range Builds
  • Hardware Tips
  • Software Tips
Search
  • Home
  • WordPress
    • Installation & Setup
    • Security
    • Solutions & Troubleshooting
    • Themes & Plugins
  • Tools
    • veo3 prompt generator
  • Our Team
    • Hosting
Follow US
Copyright © 2024 ohhmua. All rights reserved.
OhhMua > Blog > WordPress > Solutions & Troubleshooting > How to Change WordPress Login URL Without Plugins (100% Success)
Solutions & Troubleshooting

How to Change WordPress Login URL Without Plugins (100% Success)

Admin (Nghia Vo)
Last updated: September 9, 2024 4:06 pm
Admin (Nghia Vo)
Share
4 Min Read
How to Change WordPress Login URL Without Plugins
How to Change WordPress Login URL Without Plugins
SHARE

To secure a WordPress website, changing the default login URL is, in my opinion, an essential step. Additionally, this was requested by a member of a group, so today I’m sharing a PHP code that helps you change the default WordPress login URL smoothly without using a plugin.

How to Change WordPress Login URL Without Plugins
How to Change WordPress Login URL Without Plugins

Advantages:

  • No impact on website speed
  • No need for plugins
  • No direct modification of the wp-login.php file, ensuring WordPress updates don’t affect the change”

Code to change the WordPress login URL
Please add the following code to the functions.php file of your child theme.”

// change the login URL for wp ohhmua.com

// define login URL.
define('PASSCODE','loginlink');

function mask_login_url(){
  // redirect to login page when passcode is verified
  if( !is_user_logged_in() && parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY) == PASSCODE ){
    wp_safe_redirect( home_url('wp-login.php?'. PASSCODE .'&redirect=false') );
    exit();
  }
  // redirect to dashboard if the user is logged in
  if( is_user_logged_in() && parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY) == PASSCODE ){
    wp_safe_redirect( home_url("wp-admin") );
    exit();
  } 
}
add_action( 'init', 'mask_login_url');

function mask_login_redirects(){
  if( isset($_POST['passcode']) && $_POST['passcode'] == PASSCODE) return false;

  // redirect to dashboard when /wp-admin is accessed and the user is logged in
  if ( (is_user_logged_in()) && (strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false)) {
    wp_safe_redirect( home_url("wp-admin"), 302 );
    exit();
  }
  // redirect to homepage when accessing /wp-admin or /wp-login and user is not logged in
  if ( (!is_user_logged_in()) && ((strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false) || (strpos($_SERVER['REQUEST_URI'], 'wp-login') !== false)) && ( strpos($_SERVER['REQUEST_URI'], PASSCODE) === false ) ) {
    wp_safe_redirect( home_url(), 302 );
    exit();
  }
  // redirect to homepage after logout
  if( strpos($_SERVER['REQUEST_URI'], 'action=logout') !== false ){
    check_admin_referer( 'log-out' );
    wp_logout();
    wp_safe_redirect( home_url('?logged-out'), 302 );
    exit();
  } 
}
add_action( 'login_init', 'mask_login_redirects', 1);

// Add hidden passcode field to the login form
function custom_login_hidden_field(){
  echo '<input type="hidden" name="passcode" value="'. PASSCODE .'" />';
}
add_action('login_form', 'custom_login_hidden_field');
// change the login URL for wp ohhmua.com end

In the line define('PASSCODE','loginlink');, replace 'loginlink' with the login path you want.

After adding the code, your login URL will be as follows:
https://yourwebsite.com/admin?loginlink or https://yourwebsite.com/wp-admin?loginlink, which means you just add ?loginlink.

Final note:
I have tested this code multiple times and it has successfully worked on my demo website, so you can use it with confidence. If you encounter any issues during the process, feel free to contact me.

480520387 657957633334779 6814038772835954285 n
Admin (Nghia Vo)

Hi, I’m Nghia Vo: a computer hardware graduate, passionate PC hardware blogger, and entrepreneur with extensive hands-on experience building and upgrading computers for gaming, productivity, and business operations.
As the founder of Vonebuy.com, a verified ecommerce store under Vietnam’s Ministry of Industry and Trade, I combine my technical knowledge with real-world business applications to help users make confident decisions.

I specialize in no-nonsense guides on RAM overclocking, motherboard compatibility, SSD upgrades, and honest product reviews sharing everything I’ve tested and implemented for my customers and readers.

You Might Also Like

Headless vs Traditional WooCommerce: Which Architecture Wins?

Can AI Agents Safely Access Your WordPress Site?

Is WordPress Dead or Still Powering the Web in 2026?

WordPress 6.9.2 Disaster: Why You Should Never Auto-Update Immediately

Headless WordPress Explained: Is It Right for Your Site?

TAGGED:loginwordpress
Share This Article
Facebook Twitter Email Print
By Admin (Nghia Vo)
Follow:
Hi, I’m Nghia Vo: a computer hardware graduate, passionate PC hardware blogger, and entrepreneur with extensive hands-on experience building and upgrading computers for gaming, productivity, and business operations. As the founder of Vonebuy.com, a verified ecommerce store under Vietnam's Ministry of Industry and Trade, I combine my technical knowledge with real-world business applications to help users make confident decisions. I specialize in no-nonsense guides on RAM overclocking, motherboard compatibility, SSD upgrades, and honest product reviews sharing everything I’ve tested and implemented for my customers and readers.
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Trending

Customizing Canonical Tags in WordPress
Solutions & Troubleshooting

Step-by-Step Tutorial: Customizing Canonical Tags in WordPress

September 15, 2024
How to Pick the Ideal Blogging Platform for Your Needs
Solutions & Troubleshooting

How to Pick the Ideal Blogging Platform for Your Needs

April 1, 2025
Why 2 Backlinks per Article Might Be Killing Your SEO
Solutions & Troubleshooting

Why 2 Backlinks per Article Might Be Killing Your SEO

May 23, 2025
Guide to Using Multiple Domains for One WordPress Website
Solutions & Troubleshooting

Guide to Using Multiple Domains for One WordPress Website

September 16, 2024
Share a countdown button to display a password in WordPress
Solutions & Troubleshooting

Share a countdown button to display a password in WordPress

September 11, 2024
What is Obsidian
Solutions & Troubleshooting

What is Obsidian? Why Developers Love This Note-Taking App

May 20, 2025
Previous Next

You Might Also Like

WordPress 7.0 Finally Fixes 20 Years of Painful Collaboration Problems
Solutions & Troubleshooting

WordPress 7.0 Finally Fixes 20 Years of Painful Collaboration Problems

Admin (Nghia Vo) Admin (Nghia Vo) March 9, 2026
HETZNER HOSTING
Solutions & Troubleshooting

Why Hetzner Might Not Be the Right Choice for Beginners

Admin (Nghia Vo) Admin (Nghia Vo) March 7, 2026
wordpress speed 2026
Solutions & Troubleshooting

WordPress Speed in 2026: The Only Hosting Checklist You Need

Admin (Nghia Vo) Admin (Nghia Vo) March 7, 2026
What Happens When Web Hosting Companies Get Acquired
Solutions & Troubleshooting

What Happens When Web Hosting Companies Get Acquired

Admin (Nghia Vo) Admin (Nghia Vo) March 6, 2026
wordpress shortcode 1
Solutions & Troubleshooting

WordPress Shortcodes: Complete Guide to Dynamic Content

Admin (Nghia Vo) Admin (Nghia Vo) March 4, 2026
How to Make Google Understand and Value Your Content
Solutions & Troubleshooting

SEO in the Age of AI: How to Make Google Understand and Value Your Content

Admin (Nghia Vo) Admin (Nghia Vo) June 5, 2025
Previous Next
newsletter featured

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Youtube Steam Twitch Unity

Copyright © 2024 ohhmua. All rights reserved.

OhhMua

Information

  • About
  • Terms & Conditions
  • Privacy Policy
  • Editorial Standards
Welcome Back!

Sign in to your account

Lost your password?