Page 1 of 1

Add user at same time into WordPress when register/login in phpBB side

Posted: Tue Jan 30, 2018 4:01 pm
by axew3
Since 2.4.5> use this instead:


Check this for user addition at same time as soon as the registration process in phpBB finish

Force user addition in Wordpress: on first login solution

If using iframe mode, may this snippet isn't necessary, because when user register and then login via iframed phpBB into WP page, the plugin reload the Wordpress page, so add the user into Wordpress also. By the way, you may wish that when user register and then login in phpBB, is forced to be redirected into Wordpress, and added as user into Wordpress , because user isn't surfing the forum in iframe mode, nor maybe will go to visits Wordpress side. You may also want the same user redirected into phpBB, after addition in Wordpress. May not. This code can be used in several ways, with little changes as explained more below and on same inline code comments. To apply:

on your phpBB, with a text editor open file:

search for this code:

Code: Select all

function redirect($url, $return = false, $disable_cd_check = false)
	global $user, $phpbb_path_helper, $phpbb_dispatcher;
immediately after, add the follow:

Code: Select all

// START w3all redirect to WP onlogin
	// Note: this snippet code on this redirect() function should may be little bit changed and not used as is if iframe (?)
	// see class.wp.w3all-phpbb.php -> // START w3all redirect to phpBB (onlogin to add user in WP)
	// Note: the passed URL to redirect to, is not containing the string portion after '&sid=' that is cut off
	// Note: If you want pass also phpBB sid on URL (because phpBB login work also without cookie active on browser, using sid) maybe you'll remove the line more below where 'REMOVE this line'
	// Note: note also the last REMOVE hint about 'exit;' and iframe mode
	$wordpress_url = ''; // SET HERE the WordPress URL you want to point to - DO NOT ADD FINAL SLASH (or change the code below)
	 global $request;
    if( $request->variable('mode', '') == 'login' ){
     $rurl = stristr(htmlspecialchars_decode($url), '&sid=', true); // 'REMOVE this line' to pass entire URL (with also sid var included) // stristr as of PHP 5.3.0 or > 
     if( strpos($rurl, '/') == 0 ){ $rurl = trim(substr($rurl, 1)); }
     $rurl = base64_encode(generate_board_url() . '/'. str_replace('./', '', $rurl));
      header("Location: $wordpress_url/?w3allAU=$rurl"); 
     exit; // REMOVE or comment this 'exit;' if on redirect to iframe page (because login is done in iframe mode) it cause on redirect, that the iframed forum page return a blank page (iframe not loaded, even if on output source code all seem to be ok...)
// END w3all redirect to WP onlogin
on the added code, change the code line:

Code: Select all

$wordpress_url = ''; 
to point to your WordPress URL.

Note also that if you not wish to redirect users into phpBB, after they have been redirected by phpBB (onlogin) into Wordpress for addition, change this line:

Code: Select all

header("Location: $wordpress_url/?w3allAU=$rurl"); 

Code: Select all

header("Location: $wordpress_url/");
because without passing the var w3allAU and related value, the plugin will not redirect to phpBB, after user addition in Wordpress, and WordPress will be loaded.

Re: Add user at same time into WordPress when register/login in phpBB side

Posted: Fri Aug 10, 2018 6:26 pm
by axew3
For solution at same time when user terminate registration process in phpBB (linked above):
register phpbb users in wordpress at same time