Can I assign users to certain groups based on roles?

defsince78 - October 30, 2009 - 07:18

Here's what I'm trying to do ... if I can do it. I want to be to have regular user (front end users) that can register and have profiles. I pretty much have that part covered with the profile module. But I would also like to have regular user profiles separate from from staff profiles. Both would have their unique fields.

Any idea on how I can achieve this?

Off the top of my head...

Harpo - October 30, 2009 - 11:16

Make sure the Profile core module is enabled, then download and install the Profile Role module (http://drupal.org/project/profile_role). This handy module allows you to set different fields for different user roles, e.g. Favourite Staff Picks for users who have the Staff role.

When the module is enabled, you can create custom fields under the Roles tab in your Profiles admin (admin/user/profile). You can then call to these fields by their machine-readable name (e.g. fav_staff_picks) in user-profile.tpl.php which is located in your active theme like this:

<?php if($account->fav_staff_picks): ?><div id="favstaffpicks">Favouite Staff Picks: <?php print check_plain($account->fav_staff_picks); ?></div><?php endif ?>

This basically says "if there is a field called fav_staff_picks associated with this user, then print it", which means the field won't show up on non-Staff users.

I'm by no means a Drupal or PHP expert, but that worked for me. If anyone with more experience on this topic would like to contribute/correct me, go for it!

Harpo

User_types module

mittalpatel - October 30, 2009 - 11:46

I had used http://drupal.org/project/user_types module once for the same purpose.
It gives very nice control over the fields while creating the fields.

Check it out yourself.

---

 
 

Drupal is a registered trademark of Dries Buytaert.