In my project, I have user relationship module installed. I created a view of online users. I then tried to include a link to enable users "add friends or create relationship" in the view by adding the following code
global $user;
$opt = '';
$requestee_id = $row->uid;
$requester_id = $user->uid;
if (user_is_logged_in()) {
if ($requestee_id != $requester_id) {
//for friend request button
$relationships = user_relationships_load(array('between' => array($requester_id, $requestee_id)));
if (empty($relationships)) {
$opt = l(t('Add Friend') , "relationship/$requestee_id/request/1", array('html' => TRUE, 'absolute' => TRUE, 'query' => array('destination' => 'user/' . $requestee_id), 'attributes' => array('class' => array('ur-link add-friend-btn user_relationships_popup_link'))));
}
else {
foreach ($relationships as $relationship) {
if ($relationship->approved == 1 && user_relationships_ui_check_access('view', NULL, $relationship)) {
$opt = t('<span class="already-frnd">Friends</span>');
}
}
}
}
}
print $opt;
When I try to create a relationship, i am informed that "this user does not exist". Please what could I be doing wrong.
P.S: I have 2 relationships on my site. Thanks in anticipation.