Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Paul Wong-Gibbs

    (@djpaul)

    Sorry, which shortcod? The forum here ate it. (try not putting it in the square brackets.

    Also where are you using the shortcode? Adding it into a page or a post?

    mikebronner

    (@mikebronner)

    I’m having the same issue.

    I’m using the following code in a template page:

    <h2 class="entry-title"><?php _e( 'Achievements', 'achievements' ); ?></h2>
    <?php
    	echo do_shortcode('[dpa-user-achievements-index]');
    ?>

    mikebronner

    (@mikebronner)

    A little more background: I am using this shortcode on the bbpress profile page of users. The problem seems to be that the shortcode relies on the author of the page. Is there a way to pass in a user ID to override the author requirements?

    Thanks!
    ~Mike

    mikebronner

    (@mikebronner)

    After a bit more digging, I have come to the conclusion that it fails because it doesn’t detect the userid on the profile page. The following snippet should help with this, but I don’t know where in the achievement code to apply it:
    bbp_get_user_id( 0, true, false );

    I have tested this in various parts of the achievement code with success in that it prints out the code, but the if statement
    if ( dpa_has_progress() && ! empty( achievements()->achievement_query->posts ) )
    still fails in content-author-achievement.php.
    I tried in spa_has_achievements, but that function wasn’t even being fired.
    Any thoughts where this check is failing would be appreciated.

    mikebronner

    (@mikebronner)

    Should I create a new post for this issue?

    Thanks!
    ~Mike

    ifergad

    (@ifergad)

    @ mikebronner
    Hello there. Are you adding these scripts to the plugin php files or are you using shorcodes [] in a page? I am trying to create the user achievemnets’ page too, but I do not know php (trying to learn the basics through a course now), so this is not that obvious to me. Thanks a lot
    Ioanna

    mikebronner

    (@mikebronner)

    Hi Ionna,

    I am inserting the following code in a page template for user profiles on my child theme:

    <h2 class="entry-title"><?php _e( 'Achievements', 'achievements' ); ?></h2>
    <?php
    	echo do_shortcode('[dpa-user-achievements-index]');
    ?>

    Unfortunately this shortcode doesn’t run correctly if the page in question doesn’t have an author associated with it. You should be able to use this in any normal page template, though.
    ~Mike

    ifergad

    (@ifergad)

    Thanks very much Mike. I’ll try it out 🙂
    Ioanna

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    The problem seems to be that the shortcode relies on the author of the page. Is there a way to pass in a user ID to override the author requirements?

    Yes, but not trivial. Look at DPA_Shortcodes->display_user_achievements() in includes/class-dpa-shortcodes.php. It loads the content-author-achievement.php template. In that, the main stuff is a call to dpa_has_progress(). If you look at dpa_has_progress() in includes/progress/template.php, line 43ish there’s an “author” parameter (just like the standard WordPress loop).

    In theory copying the contents of the template into your theme file, and adding the author parameter based on your requirements, should do the job.

    mikebronner

    (@mikebronner)

    Hi Paul, thanks so much for responding. 🙂

    This is the what I get in $defaults when I run it on the profile page:
    array(11) { ["max_num_pages"]=> bool(false) ["order"]=> string(4) "DESC" ["orderby"]=> string(4) "date" ["paged"]=> int(1) ["post_status"]=> string(12) "dpa_unlocked" ["post_type"]=> string(12) "dpa_progress" ["s"]=> string(0) "" ["author"]=> int(1) ["post_parent"]=> NULL ["posts_per_page"]=> int(-1) ["ach_populate_achievements"]=> bool(false) }

    And here is what I get when I run it on the achievements page using the unaltered code:
    array(11) { ["max_num_pages"]=> bool(false) ["order"]=> string(4) "DESC" ["orderby"]=> string(4) "date" ["paged"]=> int(1) ["post_status"]=> string(12) "dpa_unlocked" ["post_type"]=> string(12) "dpa_progress" ["s"]=> string(0) "" ["author"]=> int(0) ["post_parent"]=> NULL ["posts_per_page"]=> int(-1) ["ach_populate_achievements"]=> bool(true) }

    To get around the ach_populate_achievements being false, I modified that setting to always be true on that given template for profiles. Voila, it worked!

    So, to avoid having to duplicate the dpa_has_progress function, I realized I can acutally pass in the parameters I need (thanks for the clean coding allowing for this!), like so:
    if ( dpa_has_progress(array("author"=>bbp_get_user_id( 0, true, false ), "ach_populate_achievements"=>true)) && ! empty( achievements()->achievement_query->posts ) )

    Thanks for giving me the nudge in the right direction, now I know how to do this for any page. 🙂 Hopefully this will help others as well.

    mikebronner

    (@mikebronner)

    Here is a link to what I was working on. The medals and ribbons are just examples, we will be updating the graphics to be uniform and align nicely: http://konb.info/forums/users/mike-bronner/

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    Good job! I’ll consider adding support for bbPress profile page user IDs in the future (we’ll see!).

    Hi,
    I’m trying to bring the members achievements to profile.php page like Mike, i guess 🙂

    Paul: Do you mean to copy the template.php or content-author-achievement.php? And then add the author parameter? I’m doing like this in my profile.php but not manage to get it work.

    <?php do_action( 'dpa_template_before_author_achievements' ); ?>
    <?php if ( dpa_has_progress(array("author"=>’ . $bp->displayed_user->id)) && ! empty( achievements()->achievement_query->posts ) ) : ?>
    <?php dpa_get_template_part( 'pagination-author-achievements' ); ?>
    <?php dpa_get_template_part( 'loop-achievements'              ); ?>
    <?php dpa_get_template_part( 'dpa_single_user_achievements' ); ?>
    <?php else : ?>
    <?php dpa_get_template_part( 'feedback-no-achievements' ); ?>
    <?php endif; ?>
    <?php do_action( 'dpa_template_after_author_achievements' ); ?>

    Mike: How did you manage to bring in the defaults? Am I suppose to do it here in profile.php? I’m not sure how to use your code.

    Thanks for any help!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘User Achievements Index Not Displaying’ is closed to new replies.