Hi,
First of all, awesome plugin! Many thanks!
I've got it installed on a staging environment and noticed the following:
- user logs in on PHPBB.
- when he goes to the main wordpress site, everything is okay.
- the second page he wants to visit on the wordpress site, he will be redirected to his WP-profile page.
I know that whenever someone logs into wordpress, he get's redirected to his profile page. But it is in this situation a bit strange.
I think the cookie only activates at the second page, somehow.
Any fixes for this?
phpbb user always ending up on wp-profile page when added on WP
-
- User w
- Posts: 7
- Joined: Wed Mar 14, 2018 3:33 pm
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: phpbb user always ending up on wp-profile page
Hello! Yes it can be of course resolved. Let check the behavior and we go to try to add the right response of the code for this situation.
Let you know as soon it will be fixed.
Let you know as soon it will be fixed.
-
- User w
- Posts: 7
- Joined: Wed Mar 14, 2018 3:33 pm
Re: phpbb user always ending up on wp-profile page
Thanks. Think it is default WordPress behavioir.
Just tested it on this forum too, and indeed.
- i log in on the forum
- click the link for "axew3.com home"
- i end up on my wordpress profile page
This is of course a strange interruption on the browsing/user experience.
Now, I've been thinking about fixing this via a snippet,
(source: https://alka-web.com/blog/how-to-restri ... matically/ )
however this will only work correctly if someone goes from the forum to the homepage.
Not if someone goes directly to another link. So maybe it needs to do something with referrer.
I think this is the flow:
PHPbb Login (user action) > (Login accepted, write cookie) > click link to something on wordpress site (user action) > page starts loading > cookie is accepted, login confirmed > WordPress sends user to 'login successful'-page (=/wp-admin/profile.php).
Just tested it on this forum too, and indeed.
- i log in on the forum
- click the link for "axew3.com home"
- i end up on my wordpress profile page
This is of course a strange interruption on the browsing/user experience.
Now, I've been thinking about fixing this via a snippet,
Code: Select all
/*Hide dashboard for certain roles*/
// Could be better adds the function to the 'init' hook and check later if it's an admin page
add_action( 'init', 'my_custom_dashboard_access_handler');
function my_custom_dashboard_access_handler() {
// Check if the current page is an admin page
// && and ensure that this is not an ajax call
if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
//Get all capabilities of the current user
$user = get_userdata( get_current_user_id() );
$caps = ( is_object( $user) ) ? array_keys($user->allcaps) : array();
//All capabilities/roles listed here are not able to see the dashboard
$block_access_to = array('subscriber', 'pending');
if(array_intersect($block_access_to, $caps)) {
wp_redirect( home_url() );
exit;
}
}
}
however this will only work correctly if someone goes from the forum to the homepage.
Not if someone goes directly to another link. So maybe it needs to do something with referrer.
I think this is the flow:
PHPbb Login (user action) > (Login accepted, write cookie) > click link to something on wordpress site (user action) > page starts loading > cookie is accepted, login confirmed > WordPress sends user to 'login successful'-page (=/wp-admin/profile.php).
-
- User w
- Posts: 7
- Joined: Wed Mar 14, 2018 3:33 pm
Re: phpbb user always ending up on wp-profile page
Actually think this code could do the same, because on every login the user already logs in on WP. So once he visit normally the site, the log in/profile would not trigger.
https://www.axew3.com/w3/forum/?post_id=2587#p2587
I'll test it.
https://www.axew3.com/w3/forum/?post_id=2587#p2587
I'll test it.
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: phpbb user always ending up on wp-profile page
Resuming
The problem is:
a new phpBB user, come to WordPress as logged in phpBB and need to be added in WP, OR login first time WordPress and need to be added in WP:
If login case, then the redirect to profile is ok as flow.
If is added on fly by valid phpBB cookie then he need may be redirected to the requested page, not wp profile.
The redirect is fired on
private static function verify_phpbb_credentials(){
inside the file class.wp.w3all-phpbb.php, that is the function "where all rotate around", because this is the function that check for existence of a valid phpBB cookie and login/add the user in case.
Since the problem is about redirect to correct url, if user come and is added on fly, and not to his profile, then is also possible to setup a var if user has been added on fly, and only in this case.
To achieve, i've think the best way could be:
--- this is the ready modified class.wp.w3all-phpbb.php if you want just replace it: ---
or download directly it on repository at wp.org:
https://plugins.trac.wordpress.org/brow ... tion/trunk
file class.wp.w3all-phpbb.php (1.8.4)
where:
change into:
and where:
ADD immediately after:
Should work fine. The file class.wp.w3all-phpbb.php has been just patched in this way on repo.
The problem is:
a new phpBB user, come to WordPress as logged in phpBB and need to be added in WP, OR login first time WordPress and need to be added in WP:
If login case, then the redirect to profile is ok as flow.
If is added on fly by valid phpBB cookie then he need may be redirected to the requested page, not wp profile.
The redirect is fired on
private static function verify_phpbb_credentials(){
inside the file class.wp.w3all-phpbb.php, that is the function "where all rotate around", because this is the function that check for existence of a valid phpBB cookie and login/add the user in case.
Since the problem is about redirect to correct url, if user come and is added on fly, and not to his profile, then is also possible to setup a var if user has been added on fly, and only in this case.
To achieve, i've think the best way could be:
--- this is the ready modified class.wp.w3all-phpbb.php if you want just replace it: ---
or download directly it on repository at wp.org:
https://plugins.trac.wordpress.org/brow ... tion/trunk
file class.wp.w3all-phpbb.php (1.8.4)
where:
Code: Select all
/* if($w3all_phpbb_lang_switch_yn == 1){
$userdata['locale'] = strtolower($phpbb_user_session[0]->user_lang) . '_' . strtoupper($phpbb_user_session[0]->user_lang);
}
*/
$user_id = wp_insert_user( $userdata );
Code: Select all
$user_id = wp_insert_user( $userdata );
$ins_coming_phpbbU = true;
Code: Select all
if(isset($_GET["w3allAU"])){
$uw = base64_decode($_GET["w3allAU"]);
header("Location: $uw"); /* Redirect to phpBB a coming 'onlogin' */
exit;
}
Code: Select all
if (isset($ins_coming_phpbbU)){
if( isset( $_REQUEST['redirect_to'] ) ){
wp_redirect($_REQUEST['redirect_to']); exit;
} else {
return;
}
}
-
- User w
- Posts: 7
- Joined: Wed Mar 14, 2018 3:33 pm
Re: phpbb user always ending up on wp-profile page when added on WP
Thanks,
i'll be testing.
Does this one need to be active?
https://www.axew3.com/w3/forum/?post_id=2587#p2587
i'll be testing.
Does this one need to be active?
https://www.axew3.com/w3/forum/?post_id=2587#p2587