myCred – Taking a chance!

This topic contains 2 replies, has 2 voices, and was last updated by  Backpacking Series 5 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #2669

    Backpacking Series
    Buyer
    Post count: 104

    Hello,

    This is a wild chance I am taking, since I noticed you have an Addon for myCred. As it happens, I have had no success in attracting support from the myCred team or related forums thus far (the plugin has changed ownership recently). And while I have no immediate requirement to buy your Addon for myCred, I thought of asking this question – in case you are working on something similar or, in general, can suggest a snippet I could reuse for the following scenario.

    I use the myCred plugin to award badges (a myCred Addon) to site contributors and want to personalize the email notification (another myCred Addon) to include the specific badge (and associated badge-image) a user has achieved. The Email Notification interface offers limited template tags for personalizing the email. For instance, Dear

    %display_name%

    will output Dear ‘John Doe’.

    However, I want the email to say “Dear John Doe, You have won the ‘Mountain-Climber badge (and include a Mountain-Climber Badge Image)'”. myCred offers the ability to create custom template tags and I would like to define one (e.g.

    %user_latestbadge_earned%

    ) in the functions.php file (for use in the myCred Email Notification). Somehow, I can not seem to make it work – I wish I had better programming skills!

    Has anyone here implemented a similar solution or can suggest a snippet I could reuse for the above scenario.? I know this is perhaps way outside of the regular support for the core UsersWP products and I would really appreciate any help.

    Kind regards,

    #2672

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    we have an example of that here: https://userswp.io/support/topic/user-informations-in-admin-email-notification/#post-1255

    For more hands on help you could contact a GD Exert here: http://geodirectoryexperts.com

    #2676

    Backpacking Series
    Buyer
    Post count: 104

    Thank you very much. Yes, myCred site does suggest few samples of their own and I tried to customize it to the above requirement. I also reviewed Stiofan’s suggested code. But, it doesn’t work to return the badge’s title or image in a test email notification. It’d be great if someone here can suggest corrections, and if not, thanks again for considering!

    
    
    add_filter( 'mycred_badge_image', 'add_user_badge_template_tag', 10, 3 );
    function add_user_badge_template_tag( $html, $image, $badge_object ) {
    	$html = str_replace( '%display_earnedbadges%', mycred_get_users_badges( $user_id ), $html );
    	return $html;
    	
    }

    Or this:

    
    
    add_filter( 'mycred_badge_image', 'add_user_badge_template_tag', 10, 3 );
    // Check if user has a badge
    $earned_badge_level = get_user_meta( $user_id, 'mycred_badge' . $badge_id, true );
    if ( $earned_badge_level != '' ) {
    	// User has earned this badge
    	if ( function_exists( 'mycred_get_badge' ) ) {
    		// Display user's earned badge
    		$badge = mycred_get_badge( $badge_id, $earned_badge_level );
    		if ( $badge->level_image !== false ) {
    			function add_user_badge_template_tag( $html, $image, $badge_object ) {
    			$html = str_replace( '%display_earnedbadges%', $badge->level_image, $html );
    			return $html;
    			}
    		}
      	}	
    }

    Kind regards

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket