Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

I installed WordPress locally now how do I login?

As long as you know the username you can have WP automatically log you in. You might need to ask your friend what that is.

Check to see if you’re logged in and if not, get user by login, set the current user along with the auth cookie then redirect to the ~~user’s admin~~ url or edit user url to change the password.

Place this in the functions.php of the currently activated theme.

add_action( 'wp', 'automatic_login' );

function automatic_login() {
    /*
    |---------------------------------------------------------------- 
    | SET THE USERNAME TO LOGIN WITH
    |---------------------------------------------------------------- 
    */

    $username = "Admin";

    /*
    |---------------------------------------------------------------- 
    | AUTOMATICALLY LOG IN | THEN CHANGE YOUR PASSWORD! 
    |---------------------------------------------------------------- 
    */

    if ( ! is_user_logged_in() && ! is_wp_error( $user = get_user_by( 'login', $username ) ) ) {

        // Clear any auth cookies
        wp_clear_auth_cookie();

        // Log the user in
        wp_set_current_user( $user->ID );
        wp_set_auth_cookie( $user->ID );

        // Admin Dashboard
        // $redirect_to = user_admin_url();

        // Go directly to the Edit User page to change your password
        $redirect_to = get_edit_user_link( $user->ID ) . '#password';
        wp_safe_redirect( $redirect_to );
        exit();
    }
}

Related Posts:

  1. How can I open up my administrative panel to everyone?
  2. Jquery no more loading, load-scripts.php not found (404)
  3. Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
  4. List User order by ID in Descending order (Backend)
  5. Admin username and password
  6. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  7. Programmatically create page when saving custom post type post
  8. retain querystring values when savincustom options in admin
  9. Help with accessing wp-admin page and resolving error messages
  10. PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
  11. Editing the term_order field
  12. Access to “My Site” is missing from the admin bar
  13. How to replace wp-admin login page to another location?
  14. How to change wp-admin and wp-login urls
  15. How can I catch WordPress custom settings page slug has already changed?
  16. Woocommerce display orders with products from specific categories to specific admins
  17. Search bar for wp menu
  18. Check if user had autologin & if so, logout
  19. Fatal error login WordPress [duplicate]
  20. Admin Panel 404 Error after login
  21. How to block specific user id in custom login form?
  22. call to undefined function mysql_connect
  23. Log out without confirmation request (nonce)
  24. admin panel – How to remove “delete” button from category editing page
  25. Has a PHP update given me a 404?
  26. Fatal error: wp-settings.php on line 199
  27. wordpress email checker on domain
  28. problem connecting to the administrator
  29. Hide Approved status for certain users in users list
  30. Having trouble creating two shortcodes, one for logged in user and one for visitors
  31. Call WP Rest-Api to GET /users/me returned NOTHING in console
  32. Class ‘WP_Privacy_Requests_Table’ not found
  33. wordpress contact form messages not sending although it saying they were sent successfully with this php code
  34. How to add a DELETE button to the “Edit User” WordPress admin page?
  35. Restrict wordpress access to logged users only
  36. Infinite loop when logging out using custom login form
  37. Menu not updating for logged in users after redirect
  38. Save custom field on WP_List_Table
  39. Create “blank” admin page without having admin-bar/admin-menu for faster load
  40. how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
  41. Issues adding Recaptcha v3 to WordPress Registration
  42. Display specific page if user signed in
  43. Change Login or Logout text based on status
  44. How to separate the taxonomies list from the form so that editing taxonmies is the same as pages and posts?
  45. Refresh page after login with litespeed cache
  46. How to disable sub menu items from being created?
  47. Redirect after login depending on the URL
  48. spl_autoload_register is slow for WordPress sites
  49. Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
  50. WP post meta – for loop inside for loop
  51. Redirecting the lost password page request when using a custon login page
  52. How do I send a POST request with params with WordPress REST API
  53. Admin backend, show post from a category and exclude the posts from subcategories
  54. wp-login.php?redirect_to=https problem
  55. HELP! Frontend User Profile Edit Won’t Update Email
  56. is_user_logged_in() not working in homepage
  57. Trying to login to my site redirects me to the first page
  58. Right way to display the_author_meta fields?
  59. Use page-templates without creating theme
  60. Get value of submit button in custom post type
  61. Admin Login Checks
  62. defined (‘ABSPATH’) false after AJAX post to other PHP-file
  63. Check if a user is logged into my WordPress site which is on a different server
  64. wp_query beginner
  65. Newbie question. Login/Registration. New PHP page
  66. I changed the password for the database user of my website, updated wp-config.php and wordpress asks to be reinstalled
  67. admin uploads pre_get_posts not working as expected
  68. Adding a sidebar to wp-login.php
  69. Issue with search form admin panel after PHP migration
  70. wordpress ajax return 0
  71. Renaming “Expand Details” within “Add Media”
  72. WordPress error on my website
  73. List users in a dropdown for login
  74. Dynamic form variables for post meta
  75. Add options to WordPress backend
  76. Styling admin page rows in order of importance (checkboxes)
  77. Include administrator in author list
  78. WordPress login not working
  79. Not logged in when using http
  80. Shortcodes (with a space) added to php Sample
  81. add bootstrap modal after login in wordpress
  82. White screen after login attempt
  83. Image not displayed
  84. Adding Media button to only pages
  85. admin-ajax.php loading many times
  86. WP Login Button for current domain
  87. Admin Login page not working at all
  88. Redirect users not logged in to the standard login page (and back) from some posts and pages
  89. What’s the .php file which generates the Custom Background page in the admin panel?
  90. Forbid certain users to access a specific page
  91. One folder to be accessible by one user
  92. Adding jquery using php function
  93. Why can’t I enter the wordpress admin interface?
  94. Check user last login date
  95. How do I change the Go To Categories link in the term_updated_messages
  96. Why can’t I enter the wordpress admin interface?
  97. What is the best way to reset the site? Different fails while set up
  98. Prevent users from display default wordpress login form
  99. login redirect based on user role not work as expected
  100. Allow direct access to files/folders within WordPress to replace wp-admin
Categories PHP Tags admin, login, php, wp-admin, xampp
Readme.txt not getting updated
Adding submenu to custom plugin menu page created with add_menu_page() function

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress