Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assigning a badge to the user logged in once an "if" condition is met?

Any tips on to how to code the assigning of a badge to the user logged  once an "if" condition is met?  


<#if finished>
}, 4000);
}, 4000)
< -- #I want to assign badge here -->


Learning Content Strategist
6 Replies 6

I got a temp solution by making an Advanced Badge Rule, however what I really want to do  for a custom solution is to write to the database a var condition that is met, and that global variable can be used in an advanced badge rule in cases there is not a predefined rule.


I used this to check to see if defaults were changed in profile. 


setting.profile.signature != 'default'

Create complex badge rule formulas with the Advanced Editor


About badge rules and supported badge criteria

Learning Content Strategist

The easiest to achieve what I understand you want to achieve (which might be wrong, so please feel free to share some more background about your badging example):

  1. Have your custom component assign a new Lithium user role to the relevant user if your condition is met
  2. Create your badge rule to assign this badge to everyone with the dedicated role from step 1
If you appreciate my efforts, please give me a kudo ↓
Accept as solution to help others find it faster.

Very helpful. This sounds like it will work however, any idea what is the script to add a logged in user to a role? 



Learning Content Strategist

ou would use the add role API call, but I'm actually it confused on how to use it since according to the documentation there seems to be a way to pass the user ID (which you can get for the current user from the context object), but I'm unclear about how to pass the role ID.
Here's the Community v1 documentation I was looking at:
If you appreciate my efforts, please give me a kudo ↓
Accept as solution to help others find it faster.

Thank you. :]
Learning Content Strategist

I published a couple of bits and bobs that add roles to users for different purposes. Maybe you'll find something helpful in there.


Long story short, add or remove a role:

<#assign result = restadmin("/roles/name/<role>/users/add?role.user=id/${}")/>
<#assign result = restadmin("/roles/name/<role>/users/remove?role.user=id/${}")/>


Welcome to the Technology board!

Curious about our platform? Looking to connect on social technology? You've come to the right place!

Are you a Khoros customer? For direct assistance from our Support team, please visit the Support Forum.