NOTE that for WP MU-MS. you have to add this step to correctly register an user:
viewtopic.php?p=7235#p7235
To correctly login the user
through the Simple Membership form:
Open
wp-w3all.php
and inside the
function wp_check_password($password, $hash, $user_id = '') {
(there are two
wp_check_password functions into the
wp_w3all.php file, maybe apply to both, but mandatory is to add it the first)
search for lines
Code: Select all
# going to use a direct query in place of get_user_by() before, or the pass hash in this case will not match
$wpu_db_utab = (is_multisite()) ? WPW3ALL_MAIN_DBPREFIX . 'users' : $wpdb->prefix . 'users';
$wpu = $wpdb->get_row("SELECT * FROM $wpu_db_utab WHERE ID = '".$user_id."'");
Just after add this code:
Code: Select all
if( empty($wpu) && !empty($_POST['swpm_user_name']) ){
$wpu = get_user_by( 'login', sanitize_user( $_POST['swpm_user_name'] ) );
$user_id = empty($wpu->ID) ? '' : $wpu->ID;
}
To correctly logout the user
on same
wp-w3all.php file search for
Code: Select all
add_action( 'wp_logout', array( 'WP_w3all_phpbb', 'wp_w3all_phpbb_logout' ) );
Just after add this:
Code: Select all
add_action('clear_auth_cookie', array( 'WP_w3all_phpbb', 'wp_w3all_phpbb_logout' ) );
To autologin the user after registration
open the file
/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
and search for the commented lines that starts with
Code: Select all
// FIX AUTOLOGIN for woocommerce or any other plugin:
Just after add this:
Code: Select all
# Available vars to check that we are on Simple Memberships action
# 'swpm_registration_submit' 'swpm_membership_level' 'swpm_level_hash'
# and maybe 'level_identifier'
if( isset($_POST['swpm_registration_submit']) && isset($_POST['password']) )
{
if( wp_check_password($_POST['password'], $wpu->user_pass, $wpu->ID) )
{
self::phpBB_user_session_set_res($wpu);
wp_safe_redirect( home_url() );
exit;
}
}
Note that
home_url() can be any other URL, for example
wp_redirect( home_url( '/my-profile/' ) );
or the default wp user dashboard
wp_redirect( admin_url('profile.php') );
that so maybe will automatically redirected to some front end user's profile page by some other plugin that hide the default WP dashboard to normal users redirecting to his own front-end profile page.
[b][size=150]NOTE that for WP MU-MS.[/size][/b] you have to add this step to correctly register an user:
https://www.axew3.com/w3/forums/viewtopic.php?p=7235#p7235
[size=140][color=#BF0040][b]To correctly login the user[/b][/color]
through the Simple Membership form:[/size]
Open [b]wp-w3all.php[/b]
and inside the [c]function wp_check_password($password, $hash, $user_id = '') {[/c]
(there are two [b][i]wp_check_password[/i][/b] functions into the [i]wp_w3all.php[/i] file, maybe apply to both, but mandatory is to add it the first)
search for lines
[code]# going to use a direct query in place of get_user_by() before, or the pass hash in this case will not match
$wpu_db_utab = (is_multisite()) ? WPW3ALL_MAIN_DBPREFIX . 'users' : $wpdb->prefix . 'users';
$wpu = $wpdb->get_row("SELECT * FROM $wpu_db_utab WHERE ID = '".$user_id."'");
[/code]
[size=140]Just after add this code:[/size]
[code]if( empty($wpu) && !empty($_POST['swpm_user_name']) ){
$wpu = get_user_by( 'login', sanitize_user( $_POST['swpm_user_name'] ) );
$user_id = empty($wpu->ID) ? '' : $wpu->ID;
}[/code]
[size=140][color=#BF0040][b]To correctly logout the user[/b][/color][/size]
on same [b]wp-w3all.php[/b] file search for
[code]add_action( 'wp_logout', array( 'WP_w3all_phpbb', 'wp_w3all_phpbb_logout' ) );[/code]
[size=140]Just after add this:[/size]
[code]add_action('clear_auth_cookie', array( 'WP_w3all_phpbb', 'wp_w3all_phpbb_logout' ) );[/code]
[size=150][b][color=#BF0040]To autologin the user after registration [/color][/b][/size]
open the file [i]/wp-w3all-phpbb-integration/[b]class.wp.w3all-phpbb.php[/b][/i]
and search for the commented lines that starts with
[code]// FIX AUTOLOGIN for woocommerce or any other plugin:[/code]
[size=140]Just after add this:[/size]
[code]# Available vars to check that we are on Simple Memberships action
# 'swpm_registration_submit' 'swpm_membership_level' 'swpm_level_hash'
# and maybe 'level_identifier'
if( isset($_POST['swpm_registration_submit']) && isset($_POST['password']) )
{
if( wp_check_password($_POST['password'], $wpu->user_pass, $wpu->ID) )
{
self::phpBB_user_session_set_res($wpu);
wp_safe_redirect( home_url() );
exit;
}
}[/code]
Note that [i][b]home_url()[/b][/i] can be any other URL, for example
[c]wp_redirect( home_url( '/my-profile/' ) );[/c]
or the default wp user dashboard
[c]wp_redirect( admin_url('profile.php') );[/c]
that so maybe will automatically redirected to some front end user's profile page by some other plugin that hide the default WP dashboard to normal users redirecting to his own front-end profile page.