Creating an iFlyChat User

Learn how to do Single sign-on integration with a PHP website

Step 1: Declare an associative array

$user = array(
'user_name' => 'testUser', // string(required)
'user_id' => '2', string (required)
'is_admin' => TRUE, // boolean (optional)
'user_avatar_url' => 'user-avatar-link', // string (optional)
'user_profile_url' => 'user-profile-link', // string (optional)
'user_roles' => 'user-role', //string if admin else associative array (optional)
'user_groups' => 'groups-user-belongs-to', // associative array (optional)
'user_relationships' => 'friends-of-user' // associative array (optional)
);

// sample $user array
$user = array(
'user_name' => 'testUser',
'user_id' => '2',
'is_admin' => TRUE,
'user_avatar_url' => '//www.gravatar.com/avatar/caef045b3bbc44130320edef1ec710fe?s=50&r=g&d=mm',
'user_profile_url' => 'http://facebook.com/sample-user-profile',
'user_roles' => 'admin',
'user_groups' => array(
'A' => 'A'
),
'user_relationships' => array(
'1' => array(
'name' => 'friend',
'plural' => 'friends',
'valid_uids' => array('1', '3')
)
)
);

Step 2: Pass this user array to the setUser() function.

$iflychat->setUser($user);

Setting the individual properties of a user.

IS_ADMIN

$iflychat = new iFlyChat(API_KEY, APP_ID, $settings);
$is_admin = TRUE;
$iflychat->setIsAdmin($is_admin);

user_avatar_url

$avatar_url = '//www.gravatar.com/avatar/caef045b3bbc44130320edef1ec710fe?s=50&r=g&d=mm'
$iflychat->setAvatarUrl($avatar_url);

user_profile_url

$profile_url = 'http://facebook.com/sample-user-profile'
$iflychat->setProfileLink($avatar_url);

relationships_set

$iflychat->setRelationshipSet(TRUE); // to allow relationships.
$iflychat->setRelationshipSet(FALSE); // to restrict realtionships.

default value is FALSE.

user_roles

// for admin
$iflychat->setRoomRoles('admin');

// for other users
$user_roles = array(
'subscriber' => 'subscriber'
);
$iflychat->setRoomRoles($user_roles);

user_groups

$user_groups = array(
'group1' => 'Sample Group'
);
$iflychat->setUserGroups($user_groups);

user_relationships

$list = array();
$list['1']['name'] = 'friend';
$list['1']['plural'] = 'friends';
$list['1']['valid_uids'] = array('3', '4', '5');
$iflychat->setUserRelationships($list);

all_roles

$user_site_roles = array(
'subscriber' => 'subscriber',
'editor' => 'editor',
'author' => 'author'
);
$iflychat->setAllRoles($user_site_roles);