/*an sdt nguoi comment */
add_filter( 'comment_text', 'edit_comment_text');
function edit_comment_text( $comment_text ) {
if(!current_user_can('administrator')){
preg_match_all('/(09|01[2|6|8|9]|0[3|7|5|8])+([0-9]{8})/m', $comment_text, $phones);
if($phones && isset($phones[0][0])){
foreach($phones[0] as $phone){
$comment_text = str_replace($phone, substr($phone, 0, -3) . '***', $comment_text);
}
}
}
return $comment_text ;
}
Tags: code