Badge OS earned user achievements widget
-
I am using badgeOS on a multisite which seems tobe functioning fine.
But the user achievement widget does not show the images on my side bar… just the badge name with a space for the image.
When testing the widget on one of the subdirectories I noticed it made the correct amount of lists but the lists are empty. No image or text.
Does anyone know how to correct this?
https://www.ads-software.com/extend/plugins/badgeos-community-add-on/
-
Hoping you have a dev server for this next bit, where needed.
If you do have a dev site that you can do this on, great, otherwise i have a workaround.
Open up the includes/widgets/earned-user-achievements-widget.php file in the badgeos plugin folder. Scroll down to about line 57, right after this bit of code:
$achievements = badgeos_get_user_achievements();
Once past that, add
print_r($achievements);
to line 57, save, and refresh a page that should be showing the widget. If you could paste any array output that shows up, that’d be awesome. It’ll help make sure we’re getting badges to display, as well as what data should display.
Just tried it out – our site is low key enough to test on for now.
here is an image of the outcome on the front end – https://gloconj.com/images/badge_view.jpg
Here is the view on the main site – bottom of side bar
https://gloconj.com/blog/featured/roscoe-lee-browne/Here is the view on the subdirectory.
https://gloconj.com/directory/Here is the output for the Main Site
My Badges</h5>Array ( [0] => stdClass Object ( [ID] => 2441 [post_type] => badge [date_earned] => 1370867723 ) [1] => stdClass Object ( [ID] => 4360 [post_type] => badge [date_earned] => 1371240069 ) ) <ul class="widget-achievements-listing"><li id="widget-achievements-listing-item-2441" class="widget-achievements-listing-item has-thumb"><a style="margin-top: -23px;" class="badgeos-item-thumb" href="https://gloconj.com/blog/badge/new-member-badge/"><img class="wp-post-image" width="50" height="47" style="display:none;visibility:hidden;" data-cfsrc="https://gloconj.com/wp-content/uploads/2013/05/new_member_badge-100x94.gif"><noscript><img class="wp-post-image" width="50" height="47" src="https://gloconj.com/wp-content/uploads/2013/05/new_member_badge-100x94.gif"></noscript></a><a class="widget-badgeos-item-title widget-badgeos-item-title" href="https://gloconj.com/blog/badge/new-member-badge/">New Member Badge</a></li><li id="widget-achievements-listing-item-4360" class="widget-achievements-listing-item"><a class="widget-badgeos-item-title widget-badgeos-item-title" href=""></a></li></ul><!-- widget-achievements-listing --></div> <div class="clear"><!-- --></div> <div class="fl w50p"> <div class="side-l"> </div> </div> <div class="fr w50p"> <div class="side-r"> </div> </div> <div class="clear"><!-- --></div>
I apologize if the sites are slow… I have all caching and cloudflare turned off for development.
Image optimization with cloudflare was still turned on so you will see the code you saw before. I have only turned off their caching.
I’ll turn IO off now for more testing.
Understandable with any lag.
Regarding the output, it’s a bit as I expected.
The main site output that you pasted above SHOULD be showing something. Based on the screenshot provided, it currently is? I see images/text for “Reviewer” badge and “New Member” badge.
However, any areas that have array() and nothing more, there’s no data to show, which would be why it’s not showing at all. The code is receiving an empty array to loop through.
This brings me back to my theory that the MU Network is a primary cause of this issue. the badgeos_get_user_achievements() function line isn’t pulling in any achievements except the ones in it’s current site, not across all of them.
hmmm… I wonder is there away to at least have it so it only shows the current site badges with out a big blank spot for the other sites badges.
That way I can at least say – these are your badges for this particular site?
I have an idea for that, give me a little bit of time to do it up a bit later.
No problem – thanks for all of your help!
Ok. Question that will ultimately shape what I provide next, based on the 2nd to last reply from you.
If there are no badges to display for the user in the current site, do you want to display a message like “No badges yet, let’s go earn some” or something lie that? Or would you prefer to hide the entire widget output if there’s no badges to display?
Oh definelty let’s go earn some, that would be awesome!
OK, this first part is going to be safe to do, as it was a change earlier that will go into a future release. In your plugin copy’s includes/widgets/earned-user-achievements-widget.php file, go to the line that says
if ( is_array( $achievements ) ) {
and change it to
if ( is_array( $achievements ) && ! empty( $achievements ) ) {
This will prevent everything inside it from displaying to the screen if there are no achievements to loop through.
This next part is wholly up to you, as there is no guarantee the developers will add anything like it in a future release and even less guarantee that it’d match what you have. However, if you want to add a message if there is nothing to display, you’ll want to change line 107, which is a } and right before the } else { that is part of the “is user logged in” if statement. So instead of } you’d have your own like below.
} else { _e( 'You do not have any badges yet, lets go earn some.', 'badgeos' ); }
Feel free to customize the text however you want. Remember this is wholly up to you and would need to be restored after future updates if the BadgeOS team doesn’t do something similar to replace.
Cool thanks, I will make the changes. Thanks again for all the help. Loving badge OS!
I made the change for the empty achievements but it’s still showing a blank spot from the other sites in the network on the widget.
I have BadgeOS network activated. To solve the problem I decided to activate it on each site itself rather than network wide. But when I did that “Community Add-on” plugin stopped working. I reinstalled it new and it’s still not working unless badge OS is network activated.
Any idea’s?
Oh and – I noticed that when I put two shortcodes on the same page only one works.
For example if I put
[badgeos_achievements_list type=badge]
[badgeos_achievements_list type= achievements]
only badge will show up.
also if I click on new members badge it takes me to a 404 page.
https://gloconj.com/badges-achievements/Should this be a new thread?
Yeah, lets get a new thread started for the last message.
Regarding the lingering widget issue, I’m more or less stumped. The alterations should have done what they intended.
- The topic ‘Badge OS earned user achievements widget’ is closed to new replies.