#61746 closed defect (bug) (worksforme)
WordPress login redirect issue
Reported by: | dipakparmar2007 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Login and Registration | Keywords: | has-testing-info |
Focuses: | Cc: |
Description (last modified by )
The 'login_redirect'
hook is not work in WordPress version 6.1.1.
I set default themes.
// Hook into the login_redirect filter add_filter('login_redirect', 'custom_login_redirect', 10, 3); function custom_login_redirect($redirect_to, $request, $user) { return home_url('/dashboard/'); }
if ( isset( $_POST['action'] ) && $_POST['action'] == 'log-in' ) { $user_login = $_POST['user_login']; $password = $_POST['password']; $user_data = array( 'user_login' => $user_login, 'user_password' => $password, 'remember' => true ); $user = wp_signon( $user_data ); if ( ! is_wp_error( $user ) ) { $user_id = $user->ID; if ( $user_id ) { $url = site_url().'/dashboard/'; wp_redirect( $url ); exit; } } else { $error_message = $user->get_error_message(); } } <form action="" method="post" class="sign-in"> <div class="form_group"> <label for="user_login"><?php _e('Username'); ?></label> <input type="text" name="user_login" class="input_control" id="user_login" value="" /> </div> <div class="form_group"> <label for="password"><?php _e('Password'); ?></label> <input type="password" class="input_control" name="password" id="password" /> </div> <div class="forgot"><a href="<?php echo site_url(); ?>/forgot-password/">Forgot Password?</a></div> <div class="form_footer"> <button type="submit"><?php _e('Log in'); ?></button> <input type="hidden" name="action" value="log-in" /> </div> </form>
Attachments (1)
Change History (7)
#3
@
3 days ago
- Component changed from General to Login and Registration
- Keywords has-testing-info added
- Severity changed from critical to normal
Testing Instructions
These steps define how to reproduce the issue and indicate the expected behavior.
Steps to Reproduce or Test
Test Page: Dashboard.
- Create the "Dashboard" page.
- Log into WordPress.
- Go to Pages > Add New Page.
- Add "Dashboard" as the title.
- Publish the page.
- Log out of the site.
- Add the test code as a must-use plugin:
- Add the
wp-content/mu-plugins/
directory. - Add a
test.php
file in that directory. - Copy and paste the following code into that file:
add_filter( 'login_redirect', 'custom_login_redirect', 10, 3 );
function custom_login_redirect( $redirect_to, $request, $user ) {
return home_url('/dashboard/');
}
- Save the file.
- Go to the login page, e.g.
http://example.com/wp-admin/
orhttp://example.com/wp-login.php
. - Enter your login credentials.
- Select/trigger/enter the Log In button.
- 🐞 Bug occurs.
Expected Results
When testing a patch to validate it works as expected:
- ✅ Should redirect to the expected page after login.
When reproducing a bug:
- ❌ Does not redirect to the expected page after login.
Supplemental Artifacts
Test Report Icons:
🐞 <= Indicates where issue ("bug") occurs.
✅ <= Behavior is expected.
❌ <= Behavior is NOT expected.
#4
@
3 days ago
Reproduction Report
This report validates that the issue can be reproduced.
Environment
- OS: macOS
- Web Server: Nginx
- PHP: 8.3.8
- WordPress: 6.6.2
- Browser: Firefox 131.0
- Theme: Twenty Twenty-Four
- Active Plugins: None
Actual Results
- ❌ Could not reproduce the reported issue.
After login, the site redirected to the Dashboard page which in my test site is http://wpdev.test/dashboard
.
Additional Notes
Works for me in my local testing.
#5
@
3 days ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Hello @dipakparmar2007,
Welcome to WordPress Core's Trac. I'm sorry to hear you are having difficulty with your site after updating to 6.6.1.
I tested (see test report comment:4) using the sample callback you shared. I'm unable to reproduce the issue. In my testing:
- The site redirects to Dashboard page.
'login_redirect'
filter is working.
I'm not sure about the extra code shared in the description, but am assuming that's the custom code being used.
As not able to reproduce and with the information shared, the reported issue does not appear to be a Core bug. Closed this ticket as worksforme
.
Where you can find help?
You can find people who are able to assist with your site in the WordPress support forums.
Please note, this Trac is used for the development of the WordPress Core software itself, not for support or assistance with individual sites, themes, frameworks, or plugins.
This hook is ilso not work in WordPress version 6.1.1 and I set default themes.