Infinite loop with login_url…
-
Hi. I’ve read some past posts regrading using the login_url filter if you have a custom landing page. I did the below, and in my mind, it should work, but I am getting an infinite loop when I go to the custom-entry page.
Any thoughts on this? Possibly, I am misunderstanding how to use login_url.
//Add this custom-entry.
add_filter( 'login_url', 'my_login_page', 10, 3 ); function my_login_page( $login_url, $redirect, $force_reauth ) { return home_url( '/custom-entry/?redirect_to=' . $redirect ); }
//Whitelist the custom-entry so that it is public and people can view it.
/** * Bypass Force Login to allow for exceptions. * * @param bool $bypass Whether to disable Force Login. Default false. * @param string $visited_url The visited URL. * @return bool */ function my_forcelogin_bypass( $bypass, $visited_url ) { // Allow these absolute URLs $allowed = array( home_url( '/custom-entry/' ), ); if ( ! $bypass ) { $bypass = in_array( $visited_url, $allowed ); } return $bypass; } add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass', 10, 2 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Infinite loop with login_url…’ is closed to new replies.