By Andy on Monday, 20 January 2020
Posted in Technical Issues
Likes 0
Views 476
Votes 0
Hi... Is there a line (or few lines) of PHP code which will assign a badge to a person (and ideally - but not essentially get it on the activity stream too)?

I know the badge ID and I know the User ID.

I know I can assign it manually in the back-end of EasySocial - but I have a form (using a 3rd Party Component) that people are completing and when they have I want to have a badge auto-assigned.

Thanks for any help you can give here.
Basically what you mean is there a PHP script auto assign a badge for those user when they achieve something?

If yes, you probably need to create a new badge for this, you can take a look one of the existing badge sample JoomlaFolder/administrator/components/com_easysocial/defaults/badges/profile.badge

Then you can add this following code into your 3rd party component under that function code.

require_once(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/easysocial.php');

// your command you can put this example name "profile.view"
// But you need to put more specific name and do not match with your existing badge command name
ES::badges()->log('com_easysocial', 'your command', 'your user id', 'your message');


Hope this will help.
·
Monday, 20 January 2020 14:23
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Arlex.... could you just explain the "YOUR COMMAND" part again? Everything else makes perfect sense and I really appreciate it.

How do I find out the the YOUR COMMAND bit would need to be?
·
Monday, 20 January 2020 21:27
·
0 Likes
·
0 Votes
·
0 Comments
·
"YOUR COMMAND" is the command or the unique identifier related to the badge. Each badge created on the site has a unique identifier, https://take.ms/b5pjx
·
Monday, 20 January 2020 21:31
·
0 Likes
·
0 Votes
·
0 Comments
·
PERFECT. Fully understood.
·
Monday, 20 January 2020 22:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks, will mark this as resolved.
·
Monday, 20 January 2020 22:51
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post