I have been doing my research and come up with what I think should work and was hoping more knowledgeable people could check my code for me. The intention is to assign a Wordpress user role for patrons and remove it from them when they end their support.
Also, I’m not positive where in my Wordpress code this belongs. (I know enough code to get me in trouble, but not enough to be 100% proficient.)
if ( !Patreon_Wordpress::isPatron( $user ) )
{
// Is not a patron
$user = wp_get_current_user();
if ( in_array( ‘patron’, (array) $user->roles ) )
{
//The user has the “patron” role
$u->remove_role( ‘patron’ );
}
$user = wp_get_current_user();
if ( !in_array( ‘patron’, (array) $user->roles ) ) {
//The user does not have the “patron” role
$u->add_role( ‘patron’ );
}
}