1

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

How can I do that?

  • which version of drupal you using? – ARUN Dec 9 '13 at 14:04
  • I am using Drupal 7 – sokratis Dec 9 '13 at 14:09
  • 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 Dec 9 '13 at 14:38
  • I think Userpoints could help but I am not sure how to use this with Rules...Can somebody help please? – sokratis Dec 9 '13 at 15:18
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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