Adding/removing user role on his login - based on non-Drupal table

1 reply [Last post]
Last seen: 11 years 12 weeks ago
Joined: 2011-03-11

Hello Chris and fellow Drupal users,

I've discovered your site yesterday while searching for my Drupal problem and the videos are awesome!

My question:

I have recently transferred a Flash/Perl card game with about 4000 users from using phpBB 3 as backend to Drupal 7 and it has worked well, but I'm hesitant to enable the forum - because some users at my old site had been freaking me out.

I would like to offer a forum at my site again, but only to the users who are playing long enough at my site and have a good enough reputation. Both informations (how many games played + reputation) are maintained by my Perl-game and are kept in non-Drupal tables (but in the same database as the Drupal tables). And I have created a Drupal user role of "trusted users".

I could modify 2 spots in my game - where the games are counted and where reputation is being changed - and then call 'insert/delete from users_roles where uid=?', but maybe there is a better spot in Drupal, where I could change a user role on his login?

I.e. a user visits my site, his reputation and number of games are checked by 2 quick select queries against my non-Drupal tables and then he's added (or removed - if his reputation has decreased) to the "trusted users" role and can write in forum + blog.

Thank you

Chris Shattuck
Last seen: 10 weeks 3 days ago
Joined: 2009-08-16
Hi Alex, I'm happy to hear

Hi Alex,

I'm happy to hear that you're finding the site useful. :)

In terms of a solution for when to add the role to a user, it seems like from a workflow point of view, both seem like they'd work. If you were doing it on login, you could add the role adding to hook_user_login ( It feels like from a workflow point of view, it would be good to add the role from in the game, since it would be more timely, but it depends on how immediate you need the change.

Sounds like you're on the right track thinking about hooking into Drupal for things like this, though. Feel free to post back with any followup questions.

Hope that's helpful!

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.