WordPress.org

Ready to get started?Download WordPress

Forums

Achievements for WordPress
[resolved] Display newest achievement/badge on users profile (8 posts)

  1. WeirdMike
    Member
    Posted 9 months ago #

    Hey there, just did a test run of the plugin and it's quite fancy!
    I would like to know how I could go about (sorry if it's been answered already) displaying the most recent achievement image on the users profile next to the profile image.

    -Thanks

    http://wordpress.org/plugins/achievements/

  2. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 9 months ago #

    Hi! Thanks!

    You'll need to be a little familiar with HTML, CSS, and PHP to get this done, but let me help get you started. Are you using Achievements with BuddyPress, or not?

  3. Leon Kiley
    Member
    Posted 9 months ago #

    I am very interested in knowing this also. Would like the 10 most recent badges to appear on the displayed user's profile, without modifying the plugin itself. Using Buddypress 1.7 and Achievements 3.5. Would basically be put in member-header.php of the buddypress/members/single template. Thanks in advance for your help, it's a great plugin! Thanks for adding live notifications to!

  4. Leon Kiley
    Member
    Posted 9 months ago #

    Nevermind, I figured it out. Did it this way:

    <?php 
    
    	$args = array(
         'type' => 'dpa_unlocked',
         'max' => 10,
         'user_id' => bp_displayed_user_id(),
    	 'sort' => 'DESC',
    
        );
    	if ( bp_has_activities( bp_ajax_querystring( $args ) ) ) : 
    
    ?>
        <?php while ( bp_activities() ) : bp_the_activity(); ?>
    
               <div class="user-badges">
                   <a href="<?php echo bp_activity_get_permalink(); ?>">
                       <?php echo get_the_post_thumbnail(bp_get_activity_item_id(), 'thumbnail'); ?>
                   </a>
               </div> 
    
        <?php endwhile; ?>
    <?php endif; ?>
  5. Leon Kiley
    Member
    Posted 9 months ago #

    Actually the bp_activity_get_permalink(); is no good. Use get_permalink(bp_get_activity_item_id()); instead.

  6. WeirdMike
    Member
    Posted 9 months ago #

    Yes, I'm using it with BuddyPress

  7. Leon Kiley
    Member
    Posted 9 months ago #

    Here is the new / improved / permanent way to display achievements in a buddypress template:

    <?php
    	// WP_Query arguments
    	$args = array (
    	'post_type'              => 'dpa_progress',
    	'post_status'            => 'dpa_unlocked',
    	'author'                 => bp_displayed_user_id(),
    	'order'                  => 'DESC',
    	'orderby'                => 'date',
    	'nopaging'		 => true
    	);
    
    	// The Query
    	$badges = new WP_Query( $args );
    ?>
    
    <?php while ($badges->have_posts()) : $badges->the_post(); ?>
         <a href="<?php echo get_permalink($post->post_parent); ?>" title="<?php esc_attr( the_title() ); ?>">
         <?php echo get_the_post_thumbnail($post->post_parent,'thumbnail'); ?>
         </a>
    <?php endwhile; ?>
    
    <?php wp_reset_postdata(); ?>

    Took me a while to figure out so I thought I'd share.

  8. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 9 months ago #

    SplendidAngst, check out the code the Leon wrote up. It should do what you want, or at least be a good start point.

    Thanks Leon!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.