Where it is showing user email address? Can you give me a screenshot?
Thread Starter
K
(@alienonline247)
When you start writing new message. in the TO section. it shows email addresses of other users. can you see it. i can send you screen later at night.
By default it shows user display name. can you please check if your users display name same as their email? You can check their names in Dashboard > Users > All Users
I have a follow up question that relates to this thread. I’m wondering if there is a way to prevent users from sharing email addresses and phone numbers via the message. Is there a way to “not send the message” if a phone number or email address is detected in the body of the message?
If you consider only valid email and phone number then it is easy, But what about user[at]example.com and thousands of variation of the email address? and same for phone number?
right now my client will be happy with just regular phone and email address stopping the message, i’m not worried about the variations… any way to do this?
add following code in your theme’s (child theme’s if any) functions.php
add_action( 'fep_action_validate_form', function( $where, $errors, $fields ) {
if ( ! in_array( $where, [ 'newmessage', 'reply', 'shortcode-newmessage' ] ) ) {
return false;
}
if ( preg_match( '/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i', $_POST['message_content'] ) ) {
$errors->add( 'message_content', __( 'You cannot send email address', 'front-end-pm' ) );
}
if ( preg_match( '/(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?/', $_POST['message_content'] ) ) {
$errors->add( 'message_content', __( 'You cannot send phone number', 'front-end-pm' ) );
}
}, 10, 3 );
Adjust regex if required.
i added it to the front end pm plugins functions.php file, fingers crossed! thank you!
As you have added plugins functions.php, next time when this plugin will be updated then your changes will be gone.
It is better to use a child theme (or custom plugin) to add this type of custom code.