Output user achievements using php or shortcode.
-
I’m building a website using Buddypress and Bbpress and I’m attempting to integrate a BadgeOS so that users can be awarded achievements for hitting post milestones and such, and also be given awards by moderators for whatever reasons.
So far it’s going well, however I’ve hit a wall with trying to display the users current awards on their profile and below their picture in the forums. I have the BadgeOS community add-on, but I’m trying to create more of an “all-in-one” profile page, and I don’t want users to have to click on a tab to see another users achievements.
Whilst browsing for a solution to this I managed to find a post by @tw2113 explaining what I thought was the perfect solution, calling achievements through a shortcode, however I can’t seem to get it to work.
I’ve got this code in my functions.php :: http://pastebin.com/4w9Tkfjv
..and I’m trying to use the following in the member-header.php file in buddypress and the “loop-single-reply.php” page in bbpress.
<?php echo do_shortcode('[custom_badgeos_user_achievements user="chris" type="badges" limit="15"]' ); ?>
I will also need to add some PHP within the shortcode to get the current user, I know this is quite a messy way to do this, but it seems logical, unless someone can provide me with php that isn’t using a shortcode. I came up with this, can’t say it works, but it’ll give you an idea of what I’m trying to do:
<?php $theusername = bp_displayed_user_mentionname(); echo do_shortcode('[custom_badgeos_user_achievements user=" . '$theusername' ." type="awards" limit="8"]'); ?>
Out of all the things I’ve done with this website, this seems like one of the easiest, but I just for the life of me can’t get anything to work. I’d greatly appreciate any help I can get with this. I’m so close to finishing this project and desperately want this feature to work!
Thanks!
James
- The topic ‘Output user achievements using php or shortcode.’ is closed to new replies.