I have a situation where I have a user who is logged into WordPress who is not in any way connected to Patreon. Let’s call them a “Player.” They enter a code from another user, who does have a subscription with Patreon–let’s call them the “Game Master.”
However, when I run \Patreon_Wordpress::isPatron( $user ) while the Player is logged in, where $user is the user object for the Game Master, the plugin returns userdata about the Player rather than the Game Master.
In this post: getUserPatronage defaults to current user even when passed a user object there is mention of a 3-day cache of userdata on the Patreon side? I tried disconnecting the site from Patreon and reconnecting as a test, but it does seem like isPatron() always returns the current user rather than the object that is passed.
The function in the plugin looks like this:
public static function isPatron( $user = false ) {
if( self::$current_user_is_patron != -1 ) {
return self::$current_user_is_patron;
}
// If user is not given, try to get the current user attribute ID will be 0 if there is no logged in user
if ( $user == false ) {
$user = wp_get_current_user();
}
$user_patronage = self::getUserPatronage();
if( is_numeric( $user_patronage ) && $user_patronage > 0 ) {
return self::$current_user_is_patron = true;
}
else {
return self::$current_user_is_patron = false;
}
}
It seems like it sets self::$current_user_is_patron
based on the output of $user_patronage = self::getUserPatronage()
without considering the $user
that is passed to the isPatron
function itself. So it’s always looking for the current user? Am I misreading this?