7

Are there any techniques out there that can put a user in a specific role into a different role automatically after they make X number of posts (core forum topics or/and replies)?

I'd like to implement a functionality where when users first register to my site they get put into a role which has limited privileges, but after certain number of posts to the forum (new topic or replies to existing) they get put into a different role that doesn't require CAPTCHA and they can post links etc. FYI using the core Forum and the Advanced Forum module.

0

2 Answers 2

9

I found a module User Stats which integrates with Rules and provides tokens like [user:post-count] which can be used for numerical comparison. Hope this helps someone else.

2

The User Stats module only has a dev version for D7 (I'm assuming this question is about D7). However, your question seems like a perfect usecase for the Goals module (disclosure: I'm the maintainer of it). Below is a possible configuration for your specific case, using Goals.

Configure a goal

Navigate to the relative path admin/config/goals/manage and use the link "Add a goal" to define just 1 goal, with a description (say):

Make X number of posts (core forum topics or/and replies).

Configure tasks

To achieve the goal "make X number of posts (core forum topics or/and replies)", define the Task(s) to be completed.

  • Post a certain number of core forum topics.
  • Post a certain number of replies.

A more advanced way to use (configure) Goals, is to configure tasks like so:

  • some tasks might have to be repeated multiple times.
  • some tasks may require some amount of time to expire in between any 2 similar tasks (eg: if a task is performed multiple times a day, only the first one counts).
  • ... (there are others ...).

Track progress while performing tasks

To track the progress made by a single user to complete some task, you only have to write the appropriate rules, using the Rules module, to record relevant events happening in your site, which are related to the completion of the various tasks.

For the goals/tasks described above as an example, you'd only need 2 (extremely basic) rules, which would be triggered like so:

  • After posting a core forum topic.
  • After posting a reply.

Note that these 2 rules can be re-used to measure progress on multiple goals (eg if your goal has a task like "after posting 1 reply", and a 2nd goal haS a task like "after posting 10 replies").

Moreover, the above challenges are pretty straight forward (basic) as examples of Challenges. But you can do this for virtually any entity for which you can think of a way to track them via the Rules module.

Use Rules to process completed goals

After all tasks specific to a goal are completed by a user, the goal is automagically marked as completed. But, there is more: you can also create additional rules that will be triggered (Rules Event) when a goal is completed by a user. With that, the answer to your question is extremely easy: perform a Rules Action to "... change the user to a different role" ... which is exactly what your question is about, no?

More of the same

Instead of the (boring) description of the goal above, you could have used a goal description like (say) "Participating User" instead. Which BTW could be a nice description of the role to be granted also.

If you then define (say) 3 more (similar) goals, with each of them an appropriate set of tasks to be completed, you could use the very same technique for goals (and/or roles) labeled something like so (if they sound familiar to something on Drupal.SE, that's purely be accident):

  • Loyal User.
  • Established User.
  • Trusted User.
  • Moderator.

More info

Refer to my answer to "How to implement gamification in a Drupal site and award incentives?" for additional details about the Goals module.

Note: Using Goals only requires typical administration tasks (configuration), though it does come with various hooks also for custom module development (if you want to).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.