Force redirect to WordPress login from phpBB

User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Force redirect to WordPress login from phpBB

Post by axew3 »

DISMISSED.
Valid as an hint, but you really should use/install the phpBB WordPress extension instead


Original question/post: viewtopic.php?f=2&t=661&p=2660#p2659

The same concept is here explained, but this is a good solution if you want let users login in phpBB:
Add user at same time into WordPress when register/login in phpBB side

You want a redirect before that the user try to login in phpBB, and should be redirected to WordPress login,
this can be achieved with easy in two ways: pure javascript but also pure php and html.

Javascript/jQuery:
open your overall_footer.html
maybe just after this line to make it simple (but would be better on overall_header.html file for the second instruction, by the way it work fine also as is)

Code: Select all

<!-- EVENT overall_footer_body_after -->
add the follow:

Code: Select all

<script type="text/javascript">
$(".quick-login").click(function(){
 window.location.replace("http://localhost/wp49/wp-login.php");
});
if(window.location.href.indexOf("mode=login") > -1) {
 window.location.replace("http://localhost/wp49/wp-login.php");
 }
</script>
change http://localhost/wp49/wp-login.php with the url you want to point to and remember to recompile the phpBB template.
First instruction:
now when an user click on the quick login form fields, assuming your theme use as class name the default one, to wrap the quick login form, so quick-login (if not change with your class name) will be redirected to the assigned url.
Second instruction:
if the url point to upc.php with a var mode set to login, then redirect to the assigned url.

Now all this is very nice until Javascript is enabled on browser, while will have no effect if js is disabled. Then there are more, really several and elegant ways to force the correct redirect in any case.

this problem resolved via php, let with a quick login problem: with js, and the above code, when user go to click into quick login form pass or username field to digit his credentials, then will be redirected before he click on login button and possibly before he start to digit, to the proper page.
Via php it is not possible the same result in same way: like the second instruction js solution do, php can only detect when the page will load successively that is the ucp.php page and that point to login (when user will click into login button).
Then in this case: remove the quick login form from template OR leave the quick login form in place and get the result editing on template file, the quick login html form to point to the login url in wp, passing correct vars names as wp expect to receive.
I stop here at moment, and hope this will be sufficient clear! In effect it is rare that js have been disabled on browser, so may this will be sufficient for you.