I am interested in assigning to user a Badge after he favorites 3 nodes. I want to do this with Flag, User badges and Rules.

How can I do that?

  • I don't know it, but rules event and condition should be described in flags documentation, and badge action should be described in Badges documentation (in both - look for the rules integration section).
    – Mołot
    Commented Dec 9, 2013 at 14:38

1 Answer 1


I would use the Goals module for this.

  1. Create a 'Favorite node' task and a 'Favorited 3 nodes' goals.
  2. Add an image to the goal. This is going to be your badge.
  3. Create an 'Add to favourites' flag.
  4. Create a rule that "records a task for goals" when a node is "flagged under 'Add to favourites'".
  5. If you don't really need the User badges module, you can create an image field called 'Badge' for the users and use the following custom module (you can find more information here):

    function MYMODULE_goals_completed_goal($goal_id, $uid) {
       $user = user_load($uid);
       $goal = goals_load($goal_id);
       $fid = $goal->goal_img['und'][0]['fid'];
       $img_title = $goal->goal_img['und'][0]['filename'];
       $edit = array();
       $edit['field_badge']['und']['0']['fid'] = $fid;
       user_save($user, $edit);
  6. If you really need the User badges module, I think you can adapt the code a bit and everything should work fine.

Your Answer

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

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