Plugin Directory

Changeset 3625941


Ignore:
Timestamp:
07/28/2026 01:15:20 PM (3 months ago)
Author:
i4awordpress
Message:

Fix contact-to-user lookup in Authenticate: honor custom DB table prefix and
match the full contact ID.

The lookup in Authenticate::getWordpressUserData() had two defects, both of
which the equivalent lookup in AutoLogin has always handled correctly:

  1. It queried the table name "wp_usermeta" literally instead of using $wpdb->usermeta. On any site with a custom database table prefix the query returned nothing. Where a leftover wp_usermeta table exists it does not even error - it just silently finds no match, so the plugin creates a duplicate WordPress account for the member rather than updating the existing one. Confirmed against a live site using a custom prefix.
  1. The LIKE pattern had no terminating semicolon, so the contact ID was matched as a prefix - a lookup for contact 12 would also match 1234 and could return the wrong WordPress user. This affects all sites, including those on the default prefix.

The query is now identical to the one in AutoLogin.php, which has been running
this form in production without issue.

Risk: on default-prefix sites $wpdb->usermeta resolves to "wp_usermeta", so
the generated SQL for defect 1 is unchanged. Defect 2 is a behavior change,
but it replaces a match that could return the wrong account.

Files changed:
trunk/src/i4aAuth/Authenticate.php
trunk/i4a-single-sign-on.php (version 3.0 -> 3.0.1)
trunk/readme.txt (Tested up to 7.0, added Changelog)

Location:
internet4associations-single-sign-on/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • internet4associations-single-sign-on/trunk/i4a-single-sign-on.php

    r3431114 r3625941  
    44 * Plugin URI: https://www.i4a.com/ams-integrations/wordpress-association-integration/
    55 * Description: Authenticate users to sign in using i4a credentials.
    6  * Version: 3.0
     6 * Version: 3.0.1
    77 * Author: Internet4Associations
    88 * Author URI: http://www.i4a.com/
  • internet4associations-single-sign-on/trunk/readme.txt

    r3452238 r3625941  
    22Tags: sso, single sign-on, membership, AMS, association management, membership management
    33Requires at least: 3.0.1
    4 Tested up to: 6.9
     4Tested up to: 7.0
    55Stable tag: 2.0
    66License: GPLv2 or later
    … …  
    9090
    91911. Plugin Settings. Enter your i4a API credentials here (received from i4a) and configure your plugin options.
     92
     93== Changelog ==
     94
     95= 3.0.1 =
     96* Fixed: the lookup that matches an i4a contact to an existing WordPress user assumed the default "wp_" database table prefix. On sites using a custom table prefix the lookup silently returned no results, which could cause a duplicate WordPress account to be created for a member instead of updating their existing one.
     97* Fixed: the same lookup matched the i4a contact ID as a partial value, so a contact ID could match a longer ID that began with the same digits (for example 12 matching 1234) and return the wrong WordPress user.
  • internet4associations-single-sign-on/trunk/src/i4aAuth/Authenticate.php

    r2926160 r3625941  
    196196                        return false;
    197197                }
    198                 $lookupQuery = "select * from wp_usermeta where meta_value like '%\"cst_id\";i:" . (int) esc_sql($i4aWPUsername) . "%'";
     198                $lookupQuery = sprintf('select * from %s where meta_value like "%s" limit 1', $wpdb->usermeta, '%\\"cst_id\\";i:' . (int) esc_sql($i4aWPUsername) . ';%');
    199199                $i4aWpUserObj = $wpdb->get_row($lookupQuery);
    200200                if (!is_object($i4aWpUserObj)) {
Note: See TracChangeset for help on using the changeset viewer.