Usage:

This filter hook enables you to influence and manipulate the WordPress field ‘nickname’ when the user is first created.

Unlike the “mbr/role/alternate” filter hook, this setting doesn’t get updated each time a user logs. The hook is only called once upon initial login so as not to disturb any other function which may rely on this setting (i.e. BuddyPress).

Parameters:

ActiveMember360 will pass the following parameters to your action function:

$nicknamecontains the default WordPress field value of “nickname”.
$first_namecontains the default WordPress field value of “first_name”, which is obtained from ActiveCampaign (first_name).
$last_namecontains the default WordPress field value of “last_name”, which is obtained from ActiveCampaign (last_name).
$arrCONTACTan array containing the contact record fields for the person who just logged in.

Example:

function my_mbr_nickname_hook($nickname, $first_name, $last_name, $arrCONTACT) {
  // In this simple example, we only check if a nickname exist and if not
  // we use the first name only.
  IF (trim($nickname) == '') :
    return ucfirst(trim($first_name));
  ENDIF;
  return $nickname;
}
add_filter('mbr/nickname', 'my_mbr_nickname_hook',10,4);