by axew3 » Tue Jan 30, 2018 4:01 pm
Since 2.4.5> use this instead:
https://www.axew3.com/w3/2022/02/phpbb- ... extension/
OBSOLETE since 2.4.4>
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:
includes/functions.php
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
// DO NOT ADD FINAL SLASH
$wordpress_url = 'https://www.axew3.com/wordpress'; // 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 = 'https://www.axew3.com/wordpress';
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");
into
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.
[color=#BF0040][size=200]Since 2.4.5> use this instead:[/size][/color]
[size=150][url]https://www.axew3.com/w3/2022/02/phpbb-wordpress-integration-common-tasks-extension/[/url][/size]
[size=200][b]OBSOLETE[/b][/size] since 2.4.4>
[size=150][b]
[color=#BF0040]Check this[/color] [url=https://www.axew3.com/w3/forums/viewtopic.php?f=2&t=835&p=3016#p3016]for user addition at same time as soon as the registration process in phpBB finish[/url][/b][/size]
[strike]
[color=#BF0040][b][size=150]Force user addition in Wordpress: on first login solution[/size][/b][/color][/strike]
[strike]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. [b]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 [/b], because user isn't surfing the forum in iframe mode, nor maybe will go to visits Wordpress side. [b]You may also want the same user redirected into phpBB, after addition in Wordpress. May not.[/b] This code can be used in several ways, with little changes as explained more below and on same inline code comments. To apply:[/strike]
[strike]on your phpBB, with a text editor open file:
[i]includes/[b]functions.ph[/b]p[/i][/strike]
[b]search for this code:[/b]
[code]function redirect($url, $return = false, $disable_cd_check = false)
{
global $user, $phpbb_path_helper, $phpbb_dispatcher;[/code]
[b]immediately after, add the follow:[/b]
[code]// 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
// DO NOT ADD FINAL SLASH
$wordpress_url = 'https://www.axew3.com/wordpress'; // 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[/code]
[b]on the added code, change the code line:[/b]
[code]$wordpress_url = 'https://www.axew3.com/wordpress'; [/code]
[b]to point to your WordPress URL.[/b]
Note also that [b]if you not wish to redirect users into phpBB[/b], after they have been redirected by phpBB (onlogin) into Wordpress for addition, change this line:
[code]header("Location: $wordpress_url/?w3allAU=$rurl"); [/code]
into
[code]header("Location: $wordpress_url/");[/code]
because without passing the var [i]w3allAU[/i] and related value, the plugin will not redirect to phpBB, after user addition in Wordpress, and WordPress will be loaded.