• Resolved iJamesPine

    (@ijamespine)


    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

    https://wordpress.org/plugins/badgeos/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter iJamesPine

    (@ijamespine)

    Given that I gave a fairly detailed explanation and have received no reply after 3 weeks is annoying. I found a fix, and it was fairly simple, another reason why someone could have responded.

    Basically the shortcode attributes don’t work with this code, not sure why, it just means I had to create two instances of the same code for the two times I will use this in my site and define the attributes in the code itself.

    Here’s the code I used for the profile page: http://pastebin.com/DDnd93Dm < this goes in your functions.php file. You change the “Parse our attributes” section to suit your needs.

    I’ve used bp_displayed_user_id() for the user attribute because I wanted to get the username of the profile the person is viewing.

    I output this code in the profile tab in Buddypress, so I used the “do_shortcode” function from WordPress to activate the shortcode through PHP.

    <?php echo do_shortcode('[custom_badgeos_user_achievements]' ); ?>

    Obviously you can play with the styles and add / change things, I’ve removed the name of the achievements as I just want the pictures to show up, by all means use the original code in my post above if that better suits your needs. Below is a link to the code I used for the forum loop (loop-single-reply.php). Oh and make sure if you’re editing Buddypress/Bbpress plugin files to copy the template into your theme folder. Otherwise you’ll loose your changes when you update, but I assume you know this if you’ve searched for this in the first place! Hope this helps those with the same problem. Happy coding!

    http://pastebin.com/75ncvFbP

    Also sort out your support, it’s terrible. – I did buy your plugin in the end also, maybe you could use the money to pay someone for the few hours it takes to help your customers.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Sorry for the delay in response James. I understand the frustration.

    The shortcode attempt from the first reply was not working likely because you were providing the user slug, when it was expecting the user ID. The functions that are used inside the shortcode are all expecting the ID, not the string version.

    Agreed with regards to moving the BuddyPress/bbPress template files into a safe location.

    Forum support should pick up again as well, for what it’s worth.

    Thread Starter iJamesPine

    (@ijamespine)

    Sorry for the seemingly angry response, it was only out of frustration as you said. Aside from that I really do love this plugin.

    While you’re here I’d like to let you know that it doesn’t play nice with the plugin WP Awesome Support. I just purchased that plugin also and I had to disable it because it was preventing the nomination shortcode from showing up entirely. I can write up a more detailed diagnostics of the bug and email it to both parties if that’s be more useful to you. But I really wish they’d work together as I have paid for both. It’s usually a simple fix with these things.

    I’d also like to know if there’s a way to change the nomination user selector dropdown to an input for the username. I will have thousands of users after launch and it’s getting crowded with just 40 beta users. Plus it uses the display name rather than the username, which is confusing when users have the same name.

    I hope you can help me with these last things, I do respect how you’ve gone back and replied to all the unresolved support queries. Let me know if you can fix it here, or if I should email BadgeOS support.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not familiar with “WP Awesome Support” at all, do you have a link to its site?

    It’s impossible for us to guarantee compatibility with every plugin ever, but we can guarantee that we try to remove compatibility issues whenever possible.

    Does the nomination shortcode just show as the shortcode text? or does it get parsed still but result in blank space?

    At the moment, I believe the select to text input would be a custom thing needing done, as I don’t believe there is any quick/easy way to do that. I can definitely see it getting crowded quick. Perhaps an enhancement ticket on GitHub to allow filtering that, as well as integrating select2. We did that with the shortcode embedder in the WP Admin, so it’s available for use. Display Name vs username could be a minor bump, though not unresolvable, depending on query method.

    Regarding the fixes for anything, it’ll depend on how big of a fix it is. If it’s something that needs to be done at the BadgeOS core level, it’ll be a longer process to get the fix out officially, but if it’s just minor conflict stuff, that’ll be instant benefit for you.

    So, any details that you can provide, including urls if possible for the shortcode issue, would help getting us on a road to hopefully fix that.

    Thread Starter iJamesPine

    (@ijamespine)

    Thanks for your fast reply Michael πŸ™‚

    Here’s the link: http://codecanyon.net/item/wp-awesome-support-responsive-ticket-system/4619686

    If you need to investigate it’s code, I can email you admin login credentials to my website. I’ve just realised that the shortcode does show up, but it’s the approve/disapprove feature that disappears. Narrows the problem down a bit. Here’s a screenshot: http://cl.ly/Yiys

    Obviously it’s impossible to guarantee support for everything, but if you could work out some form of a quick fix for me, that’d be great.

    Were you suggesting that I make an enhancement ticket on GitHub? I’ve not done that before and wouldn’t know how. But it is a useful feature if you’re interested in looking into that, I can imagine a lot of people benefiting from having the option to type the username rather than choosing from a drop down of 10,000 people with similar names.

    I was also wondering if there’s an option to make the approve / disapprove thing disappear once it’s approved? Obviously this is possible with the nomination list shortcode as you can choose to display pending / approved nominations, but it also appears above the nomination form without a choice. Not sure if I’m missing an option somewhere or it’s just something that hasn’t been added. But it’s annoying when there’s a massive list of nominations that have already been approved / denied. An effective quick fix would be to output the status of the nomination as a css class that I could set to “display:none” if approved. So for example:

    <div class="badgeos-nomination badgeos-feedback badgeos-feedback-1840">
    could be
    <div class="badgeos-nomination badgeos-feedback badgeos-feedback-1840 approved">

    Then I’d add the css:
    `.badgeos-submissions .approved {display: none;}’

    I mean that’d be a simple fix, unless you want to add that in as a feature or work out a solid hot fix.

    Thanks again for your help!

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    “If you need to investigate it’s code, I can email you admin login credentials to my website. I’ve just realised that the shortcode does show up, but it’s the approve/disapprove feature that disappears. Narrows the problem down a bit. Here’s a screenshot: http://cl.ly/Yiys

    Obviously it’s impossible to guarantee support for everything, but if you could work out some form of a quick fix for me, that’d be great.”

    I would appreciate the login, or at least a link to the site in question. Sometimes I’m able to determine issues just with frontend access.

    “Were you suggesting that I make an enhancement ticket on GitHub? I’ve not done that before and wouldn’t know how. But it is a useful feature if you’re interested in looking into that, I can imagine a lot of people benefiting from having the option to type the username rather than choosing from a drop down of 10,000 people with similar names.”

    No, I believe I already did this not long after my last reply. I know I did one within the past 48 hours. When users don’t have their own GitHub accounts, I’m more than willing to create it for them, as long as they explain their ideas in as much detail as they can.

    For the approved/denied classes, I believe that’s going to need to be a custom js solution. Best I can think of is checking the status of the nomination, and adding a class to the overall div dependent on that status. Another thought that came to me while I was checking on this one, is the badgeos_render_nomination filter. Here’s the default output for a single nomination: https://gist.github.com/tw2113/be12135414cc3ae01d33. What you could do is add a filter to the badgeos_render_nomination filter, and use the $nomination data that is passed in to create your own. It would very much be the same as what you see in the gist link, but you would be able to use get_post_meta( $nomination->ID, '_badgeos_nomination_status', true ) earlier before the div is finished and add that as an extra class.

    2 viable options right there! πŸ™‚ At least for the time being. I have listed a similar GitHub issue below regarding doing it by default.

    Select2/select input issue: https://github.com/opencredit/badgeos/issues/393
    Similar approved/denied class idea: https://github.com/opencredit/badgeos/issues/246

    Thread Starter iJamesPine

    (@ijamespine)

    For the login go to http://b.jamiepine.com (b for beta) and just create an account, I can then make you an administrator to have a poke around with the code. Don’t worry about putting in a real email if you don’t want. I can just approve it anyway. I would give you preset login credentials right here, but that’d be foolish, haha.

    The JS options sounds a little too complicated for me, but I could probably work out how to make the filter, it seems relatively straight forward. Although it would take me probably 5 times as long as it would take you, would you be able to add in the get_post_meta( $nomination->ID, '_badgeos_nomination_status', true ) part to a filter that I could add? I actually just gave writing it a shot, wasn’t going to well for me at all, could you help create it for me?

    Thanks for adding that Select2 idea to github for me also, would be good to see this implemented at some point.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    badgeosmichael is me.

    https://gist.github.com/tw2113/a64947b4a3b8decbc9c2

    Almost exactly the same output, except I added line 7, and added that new variable to the output on line 10

    Thread Starter iJamesPine

    (@ijamespine)

    Gotcha, made you an administrator πŸ™‚

    I’ve added the code (http://cl.ly/YlIj just so you can see where it is in the functions.php file), it breaks the nomination form for some reason.. I tested it several times, with the code there it just doesn’t show, and without the code it’s there again. Same thing that happened to me when I tried it.

    Without code: http://cl.ly/YkXt With code: http://cl.ly/YlCH

    You can test by clicking on awards in the top nav, if you need ftp details, message me on the site i’m @jamie

    Note if you make changes in the code they often don’t show until you press “flush cache” on the wordpress admin bar.

    Appreciate your time with this, I do apologise.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    the 3 links aren’t working at the point of this reply. It’s something on their end.

    The Awards link at the top is the list of available awards, not something for the approve/deny of a user’s nominations. Where could I see that in action, as that’s what the gist is for.

    Thread Starter iJamesPine

    (@ijamespine)

    That’s weird, the one time I use cl.ly in months, is the time it fails, here they are on hopefully a working site

    #1 http://pbrd.co/1v8rkbg
    #2 http://pbrd.co/1v8rA9W
    #3 http://pbrd.co/1v8raQU

    The awards link is just to show you how to get to the awards (achievements), click on say, the “beta tester” award, the nomination form is there.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looking over that code snippet, I missed 2 key parts.

    First was passing in the $nomination data so that we could query for the right information. The second was actually returning the customized output.

    I fixed those two inside the functions.php, so look things over and see if it’s as you need it and can work with now.

    Thread Starter iJamesPine

    (@ijamespine)

    Awesome! Yeah that works a treat, thanks for that.

    Let me know if you find the issue with the WP Awesome Support, it can’t be anything too major I’m sure.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    I have no idea what that plugin is doing, but it’s messing with the results from get_posts() which is what the nominations shortcode is using for its display.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Output user achievements using php or shortcode.’ is closed to new replies.