Join the myCred Membership Club today & Save 30% on all 3-Year plans! " Click Here To Get Started "

Adding text after my cred badges

front page Forums Community Adding text after my cred badges

This topic contains 8 replies, has 3 voices, and was last updated by Avatar She Makes Webthings 2 months, 3 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #48072
    Avatar
    She Makes Webthings

    Hello, I am using mycred with buddypress and have it appearing in the users profile. I would like to add a link after the badges that would like to a page that explains about badge earnings. Can someone help? Thank you.

    #48511
    Avatar
    Ammar Ahmed

    Hi,

    You can add the text after the badge image using mycred_badge_image filter follow the documentation:
    https://codex.mycred.me/filters/mycred_badge_image/

    Thanks,
    myCred Support

    #48676
    Avatar
    She Makes Webthings

    Do you think you can share another example? I can’t seem to figure it out. If I edit the snippet, the badges all disappear:

    function mycred_text ( $html, $image, $badge_object ) {
    echo '' ;
    }
    
    add_filter( 'mycred_badge_image', 'mycred_text', 10, 3 );
    #48866
    Avatar
    M

    You need to edit the $html and then make sure to return it.

    #49156
    Avatar
    She Makes Webthings

    Sorry I have a ticket open for this as well. I’m not sure why I’m not getting notifications from the support forum…

    Thank you for your response…but I honestly don’t understand. The snippet provided in your link is too complicated for someone who isn’t very familiar with coding in php. I am seeking support to add HTML after the badges, but am only getting clues that don’t really help. Thanks anyway.

    #49493
    Avatar
    M

    Hello,
    The snippet is actually very straight forward, did you see my message above where I said that it’s the $html variable that you need to edit and that you need to make sure to return it ?

    For example:

    
    function mycred_text ( $html, $image, $badge_object ) {
    return '<some html here that comes before or as a> <prefix>' . $html . '<some other html here that comes after or as a suffix closing the> </prefix>';
    }
    
    add_filter( 'mycred_badge_image', 'mycred_text', 10, 3 );
    

    Hope this helps you better.

    Cordially, M.

    #49499
    Avatar
    M

    Or more clearly:

    
    function mycred_text ( $html, $image, $badge_object ) {
    
    $html = '<some html here that comes before or as a> <prefix>' . $html . '<some other html here that comes after or as a suffix closing the> </prefix>';
    
    return $html;
    }
    
    add_filter( 'mycred_badge_image', 'mycred_text', 10, 3 );
    
    #49648
    Avatar
    She Makes Webthings

    As I mentioned, I don’t know php so I appreciate you taking the time to explain the $html and return function. But this snippet adds text after every badge. I am just trying to add text after the badge ‘row’ on the users profile. Can this be done or do I need to use CSS to achieve that? Thank you.

    #50109
    Avatar
    She Makes Webthings

    If anyone needs help with this. The correct code is as follows:

    function add_content_after_mycred_users_badges( $user_id, $users_badges ) {
    	echo "<div>Your Text Here</div>";
    }
    add_action( 'mycred_after_users_badges', 'add_content_after_mycred_users_badges', 10, 2 );
Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

11