Make the email and phone black out in the message content. It's possible?


Home Forums Front End PM PRO Make the email and phone black out in the message content. It's possible?

This topic is: Resolved
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #28317
    c-alle
    Participant

    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.

    #28324
    Shamim Hasan
    Keymaster

    It 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.

    #28328
    c-alle
    Participant

    I understand, I await the standard solution. You are very kind. Thanks.

    #28358
    Shamim Hasan
    Keymaster

    You 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.

    #28360
    c-alle
    Participant

    Fantastic! Thanks.

    #28672
    c-alle
    Participant
    This reply has been marked as private.
    #28693
    Shamim Hasan
    Keymaster

    It is working fine here.
    Please recheck if you have any more code which can do this.

    #28699
    c-alle
    Participant

    I 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.

    #28739
    Shamim Hasan
    Keymaster

    You can use /[^ ]+@[^ ]{5,}/ instead of /[^@\s]*@[^@\s]*\.[^@\s]*/ if that works.

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

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.