Support Forum
Hi,
How do I modify the text that gets sent via private message when a user is "mentionned" thru the Mention plugin?
Reading the doc I found:
- apply_filters(‘sph_mentions_pm_message’, $who.’ ‘.__(‘mentioned you in the forum post’, ‘sp-mentions’).’: ‘.$newpost[‘url’], $newpost, $user->ID);) – Allows modification of the message in a mentions notification when using the Private Messaging system before it is output/returned.
But I would love to see in the doc an example of how to use this.
Thanks!
You should really, of course, use the proper translation engine for this which is the correct way of doing it but the following mght work - I have not tried it.
Create a new, empty file called sp-user-functions.php in your WordPress wp-content folder.
Copy and paste the following function (use the Raw Code button for this) into this new file - plain text - and save. Remember at the top of the file before the function must be an opening php tag. At the very bottom after the function a closing php tag. There must be NO empty lines or spaces before or after these tags and the code block.
add_filter( 'sph_mentions_pm_message', 'translate_mention_text', 1, 3 ); function translate_mention_text( $text, $newpost, $user ) { return str_replace( "mentioned you in the forum post", "t'a mentionné dans le fil", $text ); }
If this fails then it is most likely that apostrophe which may need escaping. You will need to test it.
YELLOW
SWORDFISH
|
Thanks! I would never have found this.
I indeed had to escape the apostrophe, but also the French accents. So for future reference, this is what I have:
//Translates Simple Press Mentions module add_filter( 'sph_mentions_pm_message', 'translate_mention_text', 1, 3 ); function translate_mention_text( $text, $newpost, $user ) { return str_replace( "mentioned you in the forum post", "t\'a mentionné dans le fil", $text ); } add_filter( 'sph_mentions_pm_title', 'translate_mention_title', 1, 3 ); function translate_mention_title( $text, $newpost, $user ) { return str_replace( "You were mentioned in a post", "Tu es mentionné dans un fil du forum", $text ); }
1 Guest(s)