• Resolved robint

    (@robint)


    I’m trying to add the “user points” hook to an individual profile page.

    E.g

    Tim has ” % no of points” — Tim’s Profile Page

    Jack has ” % no of points” — Jack’s Profile Page

    How do I add this shortcode to author.php ?

    Robin

    https://www.ads-software.com/plugins/wordpoints/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author J.D. Grimes

    (@jdgrimes)

    You can use the wordpoints_display_points() function. You just need to provide it the user’s ID, the slug of the points type, and a “context” string.

    It would look something like this:

    echo esc_html( $author->user_firstname ) . ' has ';
    wordpoints_display_points( $author->ID, 'points', 'author-profile' );

    Thread Starter robint

    (@robint)

    I’m trying to add it to the menu bar;

    <?php
                                $points = $wordpoints_display_points();
                                ?>
    
    <li><a href="https://website.com/top-user-points/"> Points (<?php echo $wordpoints_display_points( $author->ID; ?>)</a></li>

    What have I done wrong?

    Thread Starter robint

    (@robint)

    Plugin Author J.D. Grimes

    (@jdgrimes)

    Try this:

    <li><a href="https://website.com/top-user-points/"> Points (<?php wordpoints_display_points( $author->ID, 'points', '' ); ?>)</a></li>

    If that doesn’t work, you can send me a copy of the template, or post a link to the code, and I’ll try to find the problem.

    Thread Starter robint

    (@robint)

    Nearly there,
    It’s displaying apart from the number.
    I’m adding it to the header.php

    Therefore it requires a hook call.
    Similar to;

    <?php
     $fep = new fep_main_class();
    $numNew = $fep->getNewMsgs();
    ?>

    Placed just above;

    <li><a href="https://xxxx.com/top-user-points/"> Points(<?php wordpoints_display_points( $user_info->ID, 'points', '' ); ?>)</a></li>

    Thread Starter robint

    (@robint)

    Got it to work with ;

    <li><a href="https://guysandgirls.directory/top-user-points/"> Points(<?php echo do_shortcode( '[wordpoints_points points_type="points"]' );?>)</a></li>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add Points Shortcode to PHP’ is closed to new replies.