Home › Forums › Front End PM PRO › Function active only "if" a condition occurs. › Reply To: Function active only "if" a condition occurs.
November 9, 2019 at 3:07 pm
#30982
shamim
Keymaster
You can use condition inside that function.
add_filter( 'fep_filter_message_before_send', function( $message ) {
if ( get_user_meta( get_current_user_id(), 'privacytel', true ) != 'No') {
// The @ symbol must be surrounded by character on both sides
$message['message_content'] = preg_replace( '/[^@\s]*@[^@\s]*\.[^@\s]*/', '[EMAILNASCOSTA]', $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,}/', '[TELEFONONASCOSTO]', $message['message_content'] ); # for phone numbers
}
return $message;
});