Usage:

This filter hook enables you to influence and manipulate the WordPress role (administrator, moderator, editor, etc.) for users with certain ActiveCampaign tags.

If this hook is used, the WordPress user role will be updated each time the user logs in, as well as when the “mbr_genpass” module is used.

This filter hook will remove all existing roles form the logged in user and apply the role returned by the filter.

If you wish to always retain one of the WordPress pre-defined default roles (i.e. Administrator, Editor, Author, Contributor and Subscriber ) in addition to adding/removing roles based upon tags you should use the Role To Tag Mapping extension of ActiveMember360 rather than this mbr/role/alternate filter hook.

Aside from any membership tags required to permit a login, an additional tag needs to be assigned to those individuals who should have any WordPress role other than the default (usually “subscriber”) role on the site.

Parameters:

ActiveMember360 will pass the following parameters to your action function:

$default_role contains the default WordPress role for your site.
$arrTAGS contains an array of all ActiveCampaign tag ids assigned to this user.

Example:

function my_mbr_alternate_role_hook($default_role, $arrTAGS=array()) {	
  // $default_role is the default role defined for this site	
  // $arrTAGS is an array containing the tag ids assigned to the current user
  IF (in_array(1228, $arrTAGS)) :	
    return 'administrator';	
  ELSEIF (in_array(1230, $arrTAGS)) :	
    return 'moderator';	
  ELSEIF (in_array(1232, $arrTAGS)) :	
    return 'editor';	
  ENDIF;	
  return $default_role;	
}	
add_filter('mbr/role/alternate', 'my_mbr_alternate_role_hook',1,2);