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.

Category: 
Tags: 

Ivan is the founder of Web Wash and spends most of his time consulting and writing about Drupal. He's been working with Drupal for 6 years and has successfully completed several large Drupal projects in Australia.

Connect: Twitter drupal.org LinkedIn App.net