i4w_alternate_role

Usage:

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

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

Aside from the membership tags, 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:

iMember360 will pass the following parameters to your filter function:

$default_role contains the default WordPress role for your site.
$tags contains an array of all Infusionsoft tags assigned to this user.

Example:

function my_i4w_alternate_role_hook($default_role, $tags="", $cid=0) {
  // $default_role is the default role defined for this site
  // $tags is a raw CSV string, i.e. 123,234,345,456,etc
  // containing the tags assigned to the current user
  // $cid is the user's Contact ID
  $arrTAGS = explode(',', $tags);
  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('i4w_alternate_role', 'my_i4w_alternate_role_hook', 1, 2);