Supporter/Buddypress Avatars

hello,

i was wondering if anyone knew of a way to pull this off...

i have buddypress & supporter installed and i would like to be able to add a "supporter" icon below member's buddypress avatars like they have done in the attached picture. i guess essentially it would work like the supporter widget identifying supporters.

any ideas?

thanks in advance,
gina

  • Philip John
    • DEV MAN’s Apprentice

    Hey Gina!

    I believe this would be possible, yes!

    There is a function inside Supporter called is_supporter(). When called, this returns TRUE or FALSE depending on whether that blog is a supporter blog or not.

    So the code would be something like;

    if (is_supporter($blog_id)){
        echo '<img src="supporter_badge.png" />';
    }

    The sticking point is that $blog_id bit - you will need to find out the $blog_id for that user. I'm not sure exactly how to do that.

    I'll see if Aaron can spare two minutes to provide guidance on that.

    Hope this helps!
    Phil

  • gina
    • The Bug Hunter

    ok - i tried a couple things but i am no programmer... that's why i shell out the bucks every month to be a member here.. haha!

    what am i missing here? both attempts shows the image but it shows for all blogs.. even non-supporters.

    this didn't work:

    <?php if (is_supporter($blog_id)) echo '<img src="http://www.xxxxx.com/images/pro-member.png" />

    then tried this.. fail...

    <?php
    if (is_supporter($blog_id)){
        echo '<img src="http://www.xxxxx.com/images/pro-member.png" />';
    }
    ?>

    help?

    thanks!
    gina

  • DavidM
    • DEV MAN’s Mascot

    Hey Gina,

    You're obviously placing this code in the correct place if the image is showing up in your blogs listing at all. So that is great!

    Could you let me know which theme you're working with or if this is a custom theme? My initial thought is that the variable $blog_id may need to be adjusted to the surrounding code. So I'd like to see what some of the surrounding code is, basically just see what values $blog_id would have here.

    Cheers,
    David

  • Philip John
    • DEV MAN’s Apprentice

    Gina,

    Just to be sure that $blog_id is actually set, change your code to this:

    <?php
    echo "<!-- blog_id is $blog_id -->";
    if (is_supporter($blog_id)){
        echo '<img src="http://www.xxxxx.com/images/pro-member.png" />';
    }
    ?>

    Then load up the page again, view the source code of the page and search for "blog_id". The output should be something like;

    <!-- blog_id is 2 -->

    If you don't see a number that means $blog_id is empty and you need to get it. I believe in that case the following might work:

    <?php
    global $blog_id;
    echo "<!-- blog_id is $blog_id -->";
    if (is_supporter($blog_id)){
        echo '<img src="http://www.xxxxx.com/images/pro-member.png" />';
    }
    ?>

    Try that and let us know!

    Phil

  • gina
    • The Bug Hunter

    sure.. here you go:

    <h4>Sponsor Ads:</h4><center><?php wp125_single_ad(1); ?>&nbsp;&nbsp;&nbsp;<?php wp125_single_ad(2); ?>&nbsp;&nbsp;&nbsp;<?php wp125_single_ad(3); ?>&nbsp;&nbsp;&nbsp;<?php wp125_single_ad(4); ?>&nbsp;&nbsp;&nbsp;<?php wp125_single_ad(5); ?><br><br></center>
    <?php /* Querystring is set via AJAX in _inc/ajax.php - bp_dtheme_object_filter() */ ?>
    
    <?php do_action( 'bp_before_blogs_loop' ) ?>
    
    <?php if ( bp_has_blogs( bp_ajax_querystring( 'blogs' ) ) ) : ?>
    
    	<div id="pag-top" class="pagination">
    
    		<div class="pag-count" id="blog-dir-count-top">
    			<?php bp_blogs_pagination_count() ?>
    		</div>
    
    		<div class="pagination-links" id="blog-dir-pag-top">
    			<?php bp_blogs_pagination_links() ?>
    		</div>
    
    	</div>
    
    	<?php do_action( 'bp_before_directory_blogs_list' ) ?>
    
    	<ul id="blogs-list" class="item-list">
    	<?php while ( bp_blogs() ) : bp_the_blog(); ?>
    
    <li>
    <?php
    global $blog_id;
    echo "<!-- blog_id is $blog_id -->";
    if (is_supporter($blog_id)){
        echo '<img src="http://www.xxxxx.com/images/pro-member.png" />';
    }
    ?>
    			<div class="item-avatar">
    				<a href="<?php bp_blog_permalink() ?>"><?php bp_blog_avatar('type=thumb') ?></a>
    			</div>
    
    			<div class="item">
    				<div class="item-title"><a href="<?php bp_blog_permalink() ?>"><?php bp_blog_name() ?></a></div>
    				<div class="item-meta"><span class="activity"><?php bp_blog_last_active() ?></span></div>
    
    				<?php do_action( 'bp_directory_blogs_item' ) ?>
    			</div>
    
    			<div class="action">
    
    				<?php do_action( 'bp_directory_blogs_actions' ) ?>
    
    				<div class="meta">
    					<?php bp_blog_latest_post() ?>
    				</div>
    
    			</div>
    
    			<div class="clear"></div>
    		</li>
    
    	<?php endwhile; ?>
    	</ul>
    
    	<?php do_action( 'bp_after_directory_blogs_list' ) ?>
    
    	<?php bp_blog_hidden_fields() ?>
    
    	<div id="pag-bottom" class="pagination">
    
    		<div class="pag-count" id="blog-dir-count-bottom">
    			<?php bp_blogs_pagination_count() ?>
    		</div>
    
    		<div class="pagination-links" id="blog-dir-pag-bottom">
    			<?php bp_blogs_pagination_links() ?>
    		</div>
    
    	</div>
    
    <?php else: ?>
    
    	<div id="message" class="info">
    		<p><?php _e( 'Sorry, there were no blogs found.', 'buddypress' ) ?></p>
    	</div>
    
    <?php endif; ?>
    
    <?php do_action( 'bp_after_blogs_loop' ) ?>

    thanks :slight_smile:
    gina

  • Philip John
    • DEV MAN’s Apprentice

    Gina,

    As you probably figured, the main blog ID is being returned rather than the ID of the blog in the list.

    I've tried to figure out how to grab the ID number to insert it into the blogs listing but it seems it's either very hard or impossible.

    Check out these resources that I've been looking at;
    http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/adding-static-featured-blogs-with-dynamic-authors-avatar-on-home-page/
    http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-blogs-loop/
    http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/customizing-the-blog-loop/
    http://wordpress.stackexchange.com/questions/1241/customizing-the-buddypress-blog-loop

    Phil

  • DavidM
    • DEV MAN’s Mascot

    Heya Gina, this thread has gotten a bit long. If you wouldn't mind perhaps starting afresh with a blogs directory / supporter, we'll be glad to take a look from there. We'd just like to resolve this thread as the main issue was solved in that Avatars isn't meant to work alongside BuddyPress.

    The topic of a blogs directory with Avatar badges is definitely a great idea though so if you'd like to continue that discussion, we can join in and see how we might be able to help get that working for you.

    Thanks,
    David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.