Home › Forums › Front End PM PRO › Make the email and phone black out in the message content. It's possible?
- This topic has 8 replies, 2 voices, and was last updated 6 years, 3 months ago by Shamim Hasan.
- AuthorPosts
- August 20, 2019 at 5:49 pm #28317c-alleParticipant
hi, I have a request if it’s possible. I would like email and phone numbers to be obscured by asterisks in messages exchanged between users.
Example, if the user A writes to the user B and in the content of the message he inserts an email address or a phone number (or a series of numbers greater than 4, one close to the other. Example +3965 etc…) is obscured with asterisks, so the user b receive the message will but not see the email address or the number of phone but will see a series of asterisks. It’s possible?
Thanks.
August 20, 2019 at 11:54 pm #28324Shamim HasanKeymasterIt will be possible but will not be accurate. There are many ways to write email and phone number. I can provide just simple way to replace.
August 21, 2019 at 12:37 am #28328c-alleParticipantI understand, I await the standard solution. You are very kind. Thanks.
August 21, 2019 at 7:34 pm #28358Shamim HasanKeymasterYou can add following code in your theme’s (child theme’s if you are using) functions.php
add_filter( 'fep_filter_message_before_send', function( $message ) { // The @ symbol must be surrounded by character on both sides $message['message_content'] = preg_replace( '/[^@\s]*@[^@\s]*\.[^@\s]*/', '[EMAIL]', $message['message_content'] ); # for emails // Take any string that contains only numbers, spaces and dashes, // Can optionally have a + before it. $message['message_content'] = preg_replace( '/\+?[0-9\-]{5,}/', '[PHONE]', $message['message_content'] ); # for phone numbers return $message; });It will work most of the time.
August 21, 2019 at 8:20 pm #28360c-alleParticipantFantastic! Thanks.
August 30, 2019 at 3:02 pm #28672c-alleParticipantThis reply has been marked as private.August 30, 2019 at 10:38 pm #28693Shamim HasanKeymasterIt is working fine here.
Please recheck if you have any more code which can do this.August 30, 2019 at 10:53 pm #28699c-alleParticipantI checked, I have no other code. If I send a simple message with only an email address and a phone works perfectly. If, on the other hand, I send the message I sent you before, the email is not replaced with [EMAILNASCOSTA] but a blank space appears.
Thanks.
September 1, 2019 at 11:54 am #28739Shamim HasanKeymasterYou can use
/[^ ]+@[^ ]{5,}/instead of/[^@\s]*@[^@\s]*\.[^@\s]*/if that works. - AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.