Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed always redirect to login page #2971

Merged
merged 6 commits into from
May 8, 2024

Conversation

andrewlimaza
Copy link
Contributor

  • BUG FIX: Fixed an issue where the redirect would always redirect to the login page.

The issue here was we were ommitting the redirect value entirely from the $login_form_array which would then default to setting a $redirect_to value of the REQUEST URI and it would always redirect to that URL based on the wp_login_form defaults when that parameter was missing.

This fix, fixes issues for custom redirects (snippets) as well as the Member Homepages Add On.

Setting the redirect argument to false by default as Paid Memberships Pro handles it's own redirects during the login process and this returns the expected functionality.

All Submissions:

* BUG FIX: Fixed an issue where the redirect would always redirect to the login page.

The issue here was we were ommitting the redirect value entirely from the $login_form_array which would then default to setting a $redirect_to value of the REQUEST URI and it would always redirect to that URL based on the wp_login_form defaults when that parameter was missing.

This fix, fixes issues for custom redirects (snippets) as well as the Member Homepages Add On.
Copy link
Member

@dparker1005 dparker1005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the WP developer docs, the redirect argument should always be a string:
https://developer.wordpress.org/reference/functions/wp_login_form/

In the wp_login_form() function itself, it is clear that redirect is expected to be a string as well, so passing false may throw warnings in recent versions of PHP:
https://github.com/WordPress/wordpress-develop/blob/a2bb04fc352f0b58a822ff83f3bd8ca6fed11757/src/wp-includes/general-template.php#L627

Is there a better "default" redirect argument that we can pass here?

* Pass a blank string instead of false as the esc_url will return an empty string if that is passed in.

https://github.com/WordPress/wordpress-develop/blob/a2bb04fc352f0b58a822ff83f3bd8ca6fed11757/src/wp-includes/general-template.php#L627

See docs here for more information on esc_url - https://developer.wordpress.org/reference/functions/esc_url/
@andrewlimaza
Copy link
Contributor Author

andrewlimaza commented Apr 29, 2024

According to the WP developer docs, the redirect argument should always be a string: https://developer.wordpress.org/reference/functions/wp_login_form/

In the wp_login_form() function itself, it is clear that redirect is expected to be a string as well, so passing false may throw warnings in recent versions of PHP: https://github.com/WordPress/wordpress-develop/blob/a2bb04fc352f0b58a822ff83f3bd8ca6fed11757/src/wp-includes/general-template.php#L627

Is there a better "default" redirect argument that we can pass here?

I moved over to passing an empty string instead of false. This will still work with the esc_url call that eventually happens by the wp_login_form.

I've also removed the esc_url as we escape the value on initializing the $redirect_to variable above this.

@andrewlimaza
Copy link
Contributor Author

Added blocking next release tag back to this as it's interfering with Member Homepages and a bunch of custom code that redirects members to specific pages on login.

@dparker1005 dparker1005 requested a review from ideadude May 6, 2024 14:15
@dparker1005 dparker1005 merged commit afe2ba6 into strangerstudios:dev May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants