Title: Congrats text
Last modified: August 22, 2016

---

# Congrats text

 *  Resolved [oncevision](https://wordpress.org/support/users/oncevision/)
 * (@oncevision)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/)
 * It appears that every time I save a badge, the congrats text for completing the
   badge gets messed up. If I use “&” or “”, it keeps adding html symbols.
 * We use your plugin along with LearnDash and I was wondering if there is a way,
   or can it be thought of for future releases, to make the congrats text html friendly?
   This would be a great place to be able to upsell additional products/services
   and/or action steps to move them through the system?
 * [https://wordpress.org/plugins/badgeos/](https://wordpress.org/plugins/badgeos/)

Viewing 13 replies - 1 through 13 (of 13 total)

 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240605)
 * Is this with the Auto Messages addon that you got from badgeos.org? I thought
   we had a fix out for that, but maybe not released. What version are you on if
   that’s the extension in question.
 *  Thread Starter [oncevision](https://wordpress.org/support/users/oncevision/)
 * (@oncevision)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240624)
 * I am using BadgeOS 1.4.2
    BadgeOS BadgeStack Add-On 1.0.1 BadgeOS Community Add-
   On 1.2.0 BadgeOS LearnDash Add-On 1.0.0 LearnDash LMS 2.0.3
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240714)
 * Ah, this is just an issue with our basic congrats text, not the Auto Messages
   premium extension.
 * Gimme a little bit more time to look at what we have going on, and I’ll get back
   to you with a possible solution for the time being.
 * Off the top of my head, I believe it’s because we’re filtering and sanitizing
   that field, and as is its best for basic text. I know I did fix the same type
   of issue in the Auto Messages addon I mentioned.
 *  Thread Starter [oncevision](https://wordpress.org/support/users/oncevision/)
 * (@oncevision)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240755)
 * I look forward to the update…
 * Thanks, in advance, for your time…
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240792)
 * Alright, thank you for your patience.
 * How comfortable are you with php? If you’re fairly comfy and know how to edit
   your theme, then you’ll be good to go with what will be below. If you’re not 
   comfortable at all, I’ll find another way to get this managed for you.
 * What I have below is two different filters that I worked out should do what you
   need.
 * The first filter filters for the congrats text meta field that we have set up,
   and when we’re iterating over the correct field, we add a custom sanitization
   callback. The default one is what’s causing the html entities. The one provided
   below allows those to be saved properly. It uses the [http://codex.wordpress.org/Function_Reference/wp_kses_post](http://codex.wordpress.org/Function_Reference/wp_kses_post)
   function.
 * The second filter filters the end resulting string of markup that gets used for
   the congrats text on the frontend. Despite it saving properly, it was still getting
   sanitized on its way to the user, and resulted in html entities as well there.
   So, we filter the whole string and run it through html_entity_decode() and it
   works fine. I was getting links to properly link in the congrats text.
 * Both of these can go into your theme’s functions.php file or they can be turned
   into a custom plugin, which is what I’ll do if you’re not comfortable with editing
   php at all.
 *     ```
       function oncevision_badgeos_entities_fix( $fields ) {
   
       	foreach( $fields as $key => $field ) {
       		if ( '_badgeos_congratulations_text' == $field['id'] ) {
       			$fields[ $key ]['escape_cb'] = 'wp_kses_post';
       			break;
       		}
       	}
   
       	return $fields;
       }
       add_filter( 'badgeos_achievement_data_meta_box_fields', 'oncevision_badgeos_entities_fix' );
   
       function oncevision_badgeos_entities_output( $text ) {
       	return html_entity_decode( $text );
       }
       add_filter( 'badgeos_earned_achievement_message', 'oncevision_badgeos_entities_output' );
       ```
   
 * You can rename the functions to whatever you want, but the hooks should remain
   the same.
 * Let me know if this works out to your needs or if it needs tweaked at all.
 *  [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240793)
 * This was already report in this [thread](http://wordpress.org/support/topic/congratulations-text-apostrophe-bug-report).
 * Glad to here there is a solution to this, I will test that in the day !
 * EDIT : that works ! Thank you so much 😀
 * Note : I prefer use a [site-specific](http://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/)
   plugin that the function.php theme file. It works the same, can be export to 
   another website, and another theme 🙂
 *  Thread Starter [oncevision](https://wordpress.org/support/users/oncevision/)
 * (@oncevision)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240794)
 * Thanks for the info –
 * I really am not a php expert, however, I followed:
 * Note : I prefer use a site-specific plugin rather than the function.php theme
   file. It works the same, can be export to another website, and another theme 
   🙂
 * Worked like a charm…
 * I love your plugin…
 *  [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240795)
 * That’s why you should use site-specific plugin !
 * I give you a link about that in my previous 🙂
 * You have no real php knowledge to have, it is basicly just smart copy paste. 
   🙂
    The Michael solution works right out of the box !
 *  Thread Starter [oncevision](https://wordpress.org/support/users/oncevision/)
 * (@oncevision)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240796)
 * [@x-raym](https://wordpress.org/support/users/x-raym/) You are to fast. I updated
   the post above and used your suggestion and it did work… Thank you
 *  [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240797)
 * You are welcome,
 * I had the same problem as you 😀
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240807)
 * I was burning the midnight oil last night on this, so I’m glad it worked out 
   well for more than just myself.
 *  [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240808)
 * Are you kidding ? This really makes my day !!
    I definitly think that it will
   be very useful for every Badge OS user ! I hope it will be integrated in the 
   next version of Badge OS, I can’t see why it wouldn’t.
 * Great Job Michael, as always 😉
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240809)
 * I’m a night owl, some of my best coding happens after 11pm. It happens.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Congrats text’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/badgeos_85d3bc.svg)
 * [BadgeOS](https://wordpress.org/plugins/badgeos/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/badgeos/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/badgeos/)
 * [Active Topics](https://wordpress.org/support/plugin/badgeos/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/badgeos/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/badgeos/reviews/)

 * 13 replies
 * 3 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/congrats-text/#post-5240809)
 * Status: resolved