Ivan Zugec

Drupal Consultant

How to install and setup user relationships

The user relationship module can be used to create relationships between users on your drupal site. In this example we’ll be creating a single relationship called “Friends”.

Requirements:

  1. Drupal 6
  2. User relationship module (http://drupal.org/project/user_relationships)
  3. Views module (http://drupal.org/project/views) If you want to integrate with views.

1 Install the module

Go to http://drupal.org/project/user_relationships and download the module and place it in sites/all/modules folder.

Then enable the required modules at Administer >> Site building >> Modules.

Make sure you enable the following modules:

  1. UR-API, this module is required.
  2. UR-Mailer, used to send friend request and approval emails.
  3. UR-UI, creates screens for users to manage relationships.
  4. UR-Views, integrates the module with views.

fig1.jpg

2 Create a relationship type

Next let's create a relationship type. To keep this tutorial simple let’s create a single relationship type called “Friend”.

Go to Administer >> User management >> Relationships and click on Add type.

Enter in the name friend and plural name friends. Keep requires approval ticked and tick the authenticated user check box in the role access. Then click on submit.

fig2.jpg

3 Setting up right permissions

The standard way of friending a user will be to go to their profile page (user/1) and click on a link on that page.

Go to Administer >> User management >> Permissions and set them up as the following:

  1. Tick access user profile under user module for anonymous user and authenticated user.
  2. Tick can have relationships under user_relationships_api module for authenticated user.
  3. Tick maintain own relationships under user_relationships_ui module for authenticated user.
  4. Tick view user relationships under user_relationships_ui module for authenticated user.
  5. Scroll to the bottom and click on Save permissions.

fig3.jpg

4 First test

Now we should test if we can become friends with other users, if you are logged on as admin go to another users profile page. You should see a Become name's friend link.

fig4.jpg

If you are not seeing the link there could be 2 problems:

  1. Check that you have setup the right permissions.
  2. You have customised your themes user-profile.tpl.php file.

5 Setting up emails

Now let's setup the friend request and approval emails. Go to Administer >> User management >> Relationships >> Settings. Scroll down to the Email Options field set, all emails are selected to be sent by default.

Let's be nice to our users and only have the request and approval email sent.

fig5.jpg

That's it, now you should have a simple friends system on your drupal site using the user relationships module. If anyone has any problems please comment below.

About the author: Ivan Zugec
Ivan Zugec's picture

Ivan is a Sydney Australia based Drupal Developer with over 5 years experience.

Follow:

Comments

Matt Young's picture

Submitted by Matt Young on

I tried both 6.x-1.0-rc2 and 6.x-1.0-dev and I can't get the link in step4. I've checked all the permissions and they seem to be all set. Nothing even for user 1. In user/.../edit, the "Relationship settings" fieldset is all empty for every user including user 1.

Do you have any idea what I'm doing wrong?

Michael's picture

Submitted by Michael on

Hey, thanks for this tutorial. It was most helpful and got user relationships working on my site ^_^

Anonymous's picture

Submitted by Anonymous on

I have one way relationship. User A wants to add user B to his "client" list. As it's set up now, the module says for user A to "become user B's client" -- that would mean User A would show in User B's Client List. Except, I want it to work as "add user B as a client" to user A's client list. (basically switch the direction of the relationship[). Is there a way to do this?

ositoblanco's picture

Thank you for this Tutorial. The most important thing for me was to set the permissions for relationships to get it working.

@Matt: If you are using panels or something else for the user page, disable them first and check if it's working. And: double check the permissions (Stepp 2 and 3).

Nick's picture

Submitted by Nick on

How do I get User Relationship link "Become Ivan's Friend" to show up on a node? Can this be done with Views?

Manuel's picture

Submitted by Manuel on

Hi Ivan:
I preciate your help. Every time i wanna use a module there is allways someone who help us (Drupal community users).
Thank you very much

Manuel Ruiz Alvarez's picture

Submitted by Manuel Ruiz Alvarez on

I appreciate the effort for making this tutorial.
It has helped me a lot.

Add new comment