Skip to:
Content
Pages
Categories
Search
Top
Bottom

Filter or stop email address from private message.

  • Hi,
    Please does anyone know of a snippet which i can use to filter email address or to notify Admin when a user include email address in private message.
     I dont want my user to include their  email address in private message because recently a user who happens to be a fraudster send message to many of his friends asking them to contact him through email.

    Regards
    Regards

Viewing 1 replies (of 1 total)
  • For anyone looking for same snippet, put the following code in your functions.php

     

    /*remove email addresses from private messages*/

    function wdw_remove_email_from_private_msg($message){

    $replacement = “[Warning: Contact removed]”;

    /*if you dont want any replacement text, replace the above line with

    $replacement = “”;

    */

    return preg_replace(“/[^@\s]*@[^@\s]*\.[^@\s]*/”, $replacement, $message);

    /*the code is short and works in most cases but not full proof. Check */

    }

    add_filter(‘messages_message_content_before_save’, ‘wdw_remove_email_from_private_msg’);

    add_filter(‘messages_message_subject_before_save’, ‘wdw_remove_email_from_private_msg’);

Viewing 1 replies (of 1 total)
  • The topic ‘Filter or stop email address from private message.’ is closed to new replies.
Skip to toolbar