Simple Memberships - Login Logout Autologin fixes

User avatar
axew3
w3all User
w3all User
Posts: 3103
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Skype: axewww

Re: Simple Memberships - Login Logout Autologin fixes

Post by axew3 »

Note: 3.1.6 has been released.
Check the Changelog.

It is possible now to fix once and for all any issue just doing this:

To fix the Simple Membership plugin login/logout issues, create the folder /wp-content/plugins/wp-w3all-custom/ and copy two files into it: /wp-w3all-phpbb-integration/common/custom_login.php and /wp-w3all-phpbb-integration/common/custom_functions.php

Code: Select all

== Changelog ==

= 3.1.6 =
* Release Date: 1 Nov 2026
Fixed: `public static function phpbb_update_profile($user_id, $old_user_data)` - current_user_can('edit_user') get Undefined array key 0 in /wp-includes/capabilities.php on line 75 (when user update password) on file class.wp.w3all-phpbb.php.
Fixed: `private static function create_phpBB_user($wpu, $action = ''){` on file class.wp.w3all-phpbb.php so as to correctly create a user in phpBB when they register in WordPress MU-MS.
Fixed: Removed the forced redirect inside the `private static function phpBB_user_session_set($wp_user_data){` on file class.wp.w3all-phpbb.php file to avoid redirect conflicts with other plugins.
Fixed: `function verify_phpbb_credentials(){` for the same above reason so to avoid redirect conflicts with other plugins.
Add: common/`custom_login.php` file to hook into the wp_w3all.php `wp_check_password function`, thereby easily fixing common login issues with other plugins.
Example: To fix the Simple Membership plugin login/logout issues, create the folder `/wp-content/plugins/wp-w3all-custom/` and copy two files into it: `/wp-w3all-phpbb-integration/common/custom_login.php` and `/wp-w3all-phpbb-integration/common/custom_functions.php`. Self-explanatory, simple, working example code is provided within.
User avatar
axew3
w3all User
w3all User
Posts: 3103
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Skype: axewww

Re: Simple Memberships - Login Logout Autologin fixes

Post by axew3 »

Since 3.1.6
The procedure has been added as part of the documentation:
https://www.axew3.com/w3/2025/06/wordpr ... code-file/

i assume this topic now finally, after very long time, successfully closed!? WoW
pennymachines
w3 User
w3 User
Posts: 112
Joined: Mon Feb 06, 2017 9:51 pm

Re: Simple Memberships - Login Logout Autologin fixes

Post by pennymachines »

I have removed my mu-plugin and followed your instructions. I now have custom_functions.php and custom_login.php in /plugins/wp-w3all-custom/

Tested logging in a Simple Membership subscribed user via phpBB and navigating to my Simple Membership subsite. The user is logged into Wordpress, but not Simple Membership. Do I need to adjust/edit custom_functions.php or custom_login.php?
User avatar
axew3
w3all User
w3all User
Posts: 3103
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Skype: axewww

Re: Simple Memberships - Login Logout Autologin fixes

Post by axew3 »

Please David, substitute custom_login.php and update to last 3.1.8! I messed up with this file on last 3.1.7.
It has been released, but automatically shipped to sites in about 6 hours, you can anyway download manually already:
https://wordpress.org/plugins/wp-w3all- ... tegration/

Look that users, are now added into all subsites they visits as first, and where they login after, and Simple membership should work fine now.
The custom_login.php file was containing errors! the $user_id var was never populated.
Let now what you may find out still not working, and note that an user is added into WordPress subsite o or main site, the first he will visit having a valid phpBB cookie or logging in into the site. Then to be added into any other subsite, the user have to login on each- But it can be easily changed into whatever wanted using few lines of code i think, into the custom_functions.php file.

Let know!

Code: Select all

= 3.1.8 =
* Release Date: 3 Nov 2026
Fixed: Switch queries to the WordPress MySQL Prepared Statements so to fix several functions issues on class.wp.w3all-phpbb.php, as reported by Patchstack.
Fixed: Changed public static function w3all_wp_logout($redirect = '') to be public, so it does not throw an error when called from external functions.
Fixed: WordPress Multisite: correctly add users into subsites when users come with valid phpBB credentials.
Fixed: File of the working example for the Simple Membership integration `/common/custom_login.php`
Example: So again, to fix the Simple Membership plugin login/logout issues, create the folder `/wp-content/plugins/wp-w3all-custom/` and copy two files into it: the new `/wp-w3all-phpbb-integration/common/custom_login.php` and `/wp-w3all-phpbb-integration/common/custom_functions.php`. Self-explanatory, simple, working example code is provided within.
pennymachines
w3 User
w3 User
Posts: 112
Joined: Mon Feb 06, 2017 9:51 pm

Re: Simple Memberships - Login Logout Autologin fixes

Post by pennymachines »

I updated this morning and copy pasted the new wp-w3all-custom files. Not fully tested yet, but when logged-in user tries to log out on Wordpress we get this error:

Fatal error: Uncaught Error: Call to private method WP_w3all_phpbb::w3all_wp_logout() from global scope
User avatar
axew3
w3all User
w3all User
Posts: 3103
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Skype: axewww

Re: Simple Memberships - Login Logout Autologin fixes

Post by axew3 »

Please download the just released 3.1.9, the error you reported was fixed on 3.1.8 you probably installed 3.1.7.

And look, to add users into any blog they visits having a valid phpBB session, without having to explicitly login into each blog i just tested this simple fast snippet that can be added into the custom_functions.php (will be by default added), and that can be easily improved to do all what required about roles, subscriptions or additions only into specific blogs and not etc:

useful custom snippets (will be added as examples by default) you may need

Code: Select all

# Simple Membership plugin fix logout (example)

  add_action( 'init', 'w3_swpm_user_logout', 1);  // 1 so to exec this before others wp_w3all hooks

  function w3_swpm_user_logout() {

  // Maybe nonces checks should be added
  if ( isset($_GET['swpm-logout']) OR isset($_GET['action']) && $_GET['action'] == 'logout' )
  {
     if ( class_exists('SwpmAuth') ) {
      $auth = SwpmAuth::get_instance();
       if ($auth->is_logged_in()) {
        SwpmAuth::get_instance()->logout();
       }
    }

    WP_w3all_phpbb::w3all_wp_logout();
   }

  }


 # Login the user into Simple Membership if it is not already

 add_action( 'init', 'w3_swpm_user_login');

  function w3_swpm_user_login() {

   if ( is_user_logged_in() && class_exists('SwpmAuth') ) {

    $auth = SwpmAuth::get_instance();
     if( !$auth->is_logged_in() ) {
      $auth->login_to_swpm_using_wp_user( wp_get_current_user() );
     }

   }
  }


  # WP MUMS Multisite: addition of the phpBB user presenting valid credentials into any WP subsite as subscriber
  # without having to login (example)

  add_action( 'init', 'w3_add_phpbbUser_anyBlog');

  function w3_add_phpbbUser_anyBlog() {

    global $w3all_phpbb_usession;

    if ( is_multisite() && !empty($w3all_phpbb_usession) && ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) {

      $role = 'subscriber';
      $result = add_user_to_blog(get_current_blog_id(), get_current_user_id(), $role);
    }
  }
[UPDATED]