Endpoint after Buddypress registration on wordpress

deltavlokkies
Posts: 4
Joined: Sat Jan 30, 2021 7:49 pm

Endpoint after Buddypress registration on wordpress

Post by deltavlokkies »

Hi,

I just installed and configured the phpbb plugin for wordpress.
There's only one bug I cant seem to fix.

When a users orders something from the site it won't direct them to the "order -received" endpoint from woocommerce.

Is there a way to fix it?
User avatar
axew3
w3all User
w3all User
Posts: 2689
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Endpoint after registration on wordpress

Post by axew3 »

Strange that the integration code interact with this, since the redirection happen in theory, only when the user login happen.
So please can you post more or less the flow/config you use in woocommerce to help me setup my example like your and test out?
"order -received" endpoint
i will check asap for this in the hope it is installed by default into pages created when woocommerce installed. It is very long time i do not give a try to it.
User avatar
axew3
w3all User
w3all User
Posts: 2689
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Endpoint after registration on wordpress

Post by axew3 »

nope, tested and yes it is as you describe. Registering new account along with placing an order in woocommerce, it redirect to home. I will check for a fix asap and return in reply here
User avatar
axew3
w3all User
w3all User
Posts: 2689
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Endpoint after Buddypress registration on wordpress

Post by axew3 »

Ok, this is the long story short:

when an user place an order in woocommerce and then go to create together with an user account, the

Code: Select all

private static function create_phpBB_user($wpu){
on class.wp.w3all-phpbb.php fire:
the user is created in phpBB, but there is an autologin that occur in wp (or i have not find out an option that let me decide is users will auto login or nor, in case please let know if there is this option so i can test the solution also for this).

After this function end, the subsequent that will fire will be

Code: Select all

private static function verify_phpbb_credentials(){
here the problem come out, because the session of phpBB has not been released, may because woocommerce do not fire the default login wp hook, or it is may fired after private static function verify_phpbb_credentials(){ that's on init. The phpBB cookie do not exist, the logout will happen.

To cut the head to the bull, to fix the issue, you should do this

open:
/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
search for this code:

Code: Select all

     $w3phpbb_conn->query("UPDATE ".$w3all_config["table_prefix"]."config SET config_value = '$wpul' WHERE config_name = 'newest_username'");
     $w3phpbb_conn->query("UPDATE ".$w3all_config["table_prefix"]."config SET config_value = '$uid' WHERE config_name = 'newest_user_id'");
 
  }
that's inside the function
private static function create_phpBB_user($wpu){
and just after the closing }
and before the very last closing } function character,
so substantially JUST BEFORE the closing function character }
add this:

Code: Select all

  if(isset($_POST['woocommerce-process-checkout-nonce']) && isset($_POST['createaccount']) && $_POST['createaccount'] == 1 ){
     if( ! defined("W3ALL_SESSION_ARELEASED") && ! defined("PHPBBAUTHCOOKIEREL") ){ 
     $phpBB_user_session_set = self::phpBB_user_session_set($wpu);
     define("W3ALL_SESSION_ARELEASED", true);
    }
  }
  
  return;
Now all will work as expected. The code can be leaved in place, and be part of the plugin because with little changes, it will return to be useful for all others plugins that goes to autologins users in several ways after registration.

in attach if you do not want to edit yourself, this is the class.wp.w3all-phpbb.php ready with modification as above explained
class.wp.w3all-phpbb.zip
(32.71 KiB) Downloaded 158 times
deltavlokkies
Posts: 4
Joined: Sat Jan 30, 2021 7:49 pm

Re: Endpoint after Buddypress registration on wordpress

Post by deltavlokkies »

Alright, thank you for the help so far.
I replaced the file like you said, but so far no dice. After the users places a order on the site, it still redirects them to the home page..
User avatar
axew3
w3all User
w3all User
Posts: 2689
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Endpoint after Buddypress registration on wordpress

Post by axew3 »

mh strange:
into my tests all works fine.
May the $_POST vars are not filled into your configuration?

can you so try to change the code into this:

Code: Select all

    if( ! defined("W3ALL_SESSION_ARELEASED") && ! defined("PHPBBAUTHCOOKIEREL") ){ 
     $phpBB_user_session_set = self::phpBB_user_session_set($wpu);
     define("W3ALL_SESSION_ARELEASED", true);
    }
the file is this:
class.wp.w3all-phpbb.zip
(32.71 KiB) Downloaded 159 times
and check if now works into your now?
woocheckoutconfirm.jpg
woocheckoutconfirm.jpg (239.75 KiB) Viewed 2791 times
Post Reply