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

Newbie question. Login/Registration. New PHP page

WordPress Core provides a lot of helper functions to accomplish these types of tasks. If it’s not a function, then there most often is a filter or action that you can hook into.

In the case of the WordPress login form, it’s wp_login_form(). Here documentation on that:
https://codex.wordpress.org/Function_Reference/wp_login_form

Regarding redirecting users after login, there’s a filter for that. This code is a snippet I’ve used on many sites:

function wip_login_redirect( $url, $request, $user ){
 $slug = $_SERVER["REQUEST_URI"];
 $islogin = strpos($slug, 'log-in');

 if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {

 if(($user->has_cap('edit_users')) && ($islogin==true)) {
 $url = admin_url('index.php');
 } elseif ((!$user->has_cap('edit_users')) && ($islogin==true)) { 
 $url = home_url();
 } else {
 $url = $slug;
 }
 }
 return $url;
}

add_filter('login_redirect', 'wip_login_redirect', 10, 3 );

I go into detail about that in this article:
https://wordimpress.com/conditional-custom-login-redirects-wordpress/

Hope that gets you going in the right direction.

Related Posts:

  1. How build a custom login/register form with error handling?
  2. Remove username in emails or swap username for email
  3. Passing the page ID to a login php script
  4. WordPress shows registration link for non logged users
  5. Is it necessary to sanitize wp_set_password user input?
  6. How to give new users two specific user role options upon WordPress user registration
  7. User management system similar to wordpress one?
  8. Issues adding Recaptcha v3 to WordPress Registration
  9. How do I do so that people can register on my wordpress site?
  10. Check if wp-login is current page
  11. Sending the reset password link programatically
  12. Getting only direct child pages in WordPress with get_pages
  13. User registration followed by automatic login
  14. Disable Attachment Pages Completely
  15. How to add a .php file to WordPress
  16. How to Remove all Instances of edit_post_link
  17. Any guides on creating custom admin pages?
  18. Adding “Remember Me” in custom login
  19. Multiple is_page() in page.php
  20. How to change the wp-login.php page title?
  21. How to check if feed URL was requested?
  22. Integrating WordPress to my website, while keeping my own authentication system
  23. Create WordPress pages with PHP
  24. Change the footer text on the login page
  25. Changing user_nicename
  26. How to disable wordpress confirmation email for new users
  27. Is it possible to generate a page without create in the admin?
  28. How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
  29. WordPress admin never finishes saving page on site with large page count
  30. class=”parent” for wp_list_pages?
  31. wordpress separate registration for different roles
  32. PHP Script within wordpress theme
  33. WordPress 4 invalid username special charachters issue
  34. How to place login logout link on menu that redirects users back to current page?
  35. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  36. add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
  37. Authenticating to WordPress, using my own authentication two-factor system
  38. Listing all sub-pages?
  39. Best way to create a user programatically
  40. How to resolve error “Cookies are blocked due to unexpected output.”?
  41. How to link to a custom .php page in my folder
  42. How to add specific menu on a specific page or pages
  43. Using a nonce in a Custom Login Form
  44. Why when I instantiate wp_error in a validation method my user registration method stops working?
  45. Get only the grandchildren, not the direct children of page/current page?
  46. Constructing a custom login form using ajax
  47. automated tests as a user?
  48. Help with a custom page template – listing contents of childpages?
  49. Print number of post (in reverse)
  50. woocommerce and is_user_logged_in() if not redirect to homepage
  51. Trigger Woocommerce New User Email
  52. How can the plugin directory path be returned into ?
  53. How to send user data in json format to another server when user register on wordpress site in PHP
  54. Check if user is logged in when clicking certain links on certain pages
  55. items_wrap not working
  56. Add a Different CSS Class Into The Body Tag of Different WP Pages
  57. PHP If user is logged in & on home page redirect
  58. Creating login session via CURL
  59. Limit get_pages to only show 5 items
  60. syntax issue on php 7.4
  61. How do I publish only one page to production after making changes on staging?
  62. Admin username and password
  63. Custom Template 404 for specific custom post type
  64. Can’t load WP function into external function
  65. Custom category code not showing all posts
  66. Recovering WP Login Credintials in Code?
  67. What’s the best user registration library to integrate WordPress?
  68. Insert a button on a page with random number generation
  69. Anyway to output the registration form like the login form with wp_login_form()?
  70. WordPress custom login form using Ajax
  71. Can’t get page content in WordPress
  72. Way to querry data (tags) from a wordpress database?
  73. Global variable $post returning incorrect object
  74. How can I load a PHP page without using a Template?
  75. Redirect to a different page through registration, depending on page
  76. Best practice for migration friendly images in posts/pages?
  77. How to redirect login and register pages
  78. Page Automatically Generated from Theme?
  79. Wp-login appears White Screen, Error: Cannot modify header information
  80. How to: PHP Log Out Link?
  81. Login/logout in header
  82. How to add a php custom page to WordPress
  83. Why is my cookie not unsetting upon logout? [closed]
  84. Sort query_posts for Parent Pages to menue order or the count?
  85. How to hide all child pages with post_query?
  86. Custom user login page by creating a plugin
  87. Programmatic Login from 3rd Party site
  88. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  89. How to debug my custom login form looping intermittently
  90. How can I save unique user data on my site? [closed]
  91. user_profile_update_errors hook not executing
  92. getting logged in user info (wp-load.php) from parent directory
  93. My page.php shows the index.php
  94. Populate editor with some content of a page with a page template
  95. Paypal form integration with wordpress registration form without plugin [closed]
  96. How can I add an area/option for a custom page description?
  97. Create Page To Count Comments For Each Post In WordPress Site
  98. WordPress post-template null warnings
  99. Can’t programmatically log user in php
  100. Custom theme on multisite has issues with standard loop output
Categories PHP Tags login, pages, php, user-registration
Search by tag, category and author without plugin
why featured image option isn’t showing in custom post type?

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