add_filter ('get_comment_author', 'my_comment_author', 10, 1);
function my_comment_author ($author = '') {
$comment = get_comment ($ comment_ID);
if(! empty ($ comment-> comment_author)) {
if($ comment->user_id> 0) (
$user = get_userdata ($comment-> user_id);
$first_name = substr($user->first_name, 0, 1).str_repeat('*', strlen($user->first_name)-1);
$last_name = substr($user->last_name, 0, 1).str_repeat('*', strlen($user->last_name)-1);
$author = $first_name + ' ' + $last_name;
} else {
$author = __ ('Anonymous');
}
} else {
$author = $comment-> comment_author;
}
return $author;
}Şöyle deneyin, test edenemedim ama çalışması lazım.
Şu şekilde bir hata alıyorum:
PHP kod değişiklikleriniz wp-content/themes/martfury/functions.php dosyasındaki satır 95 yüzünden geri alındı. Lütfen düzeltin ve tekrar kaydetmeyi deneyin.
syntax error, unexpected 'comment_ID' (T_STRING), expecting variable (T_VARIABLE) or '{' or '$'95. satır:
$comment = get_comment ($ comment_ID);
@Scorpion2763;
Kodu aşağıdaki şekilde esas tema içerisindeki "functions.php" dosyasına ekledim. Ancak sadece isimden sonra nokta koydu.
Örneğin Mahmut Tan adında;
Mahmut T.
add_filter('get_comment_author', 'my_comment_author', 10, 1);
function my_comment_author( $author = '' ) {
// Get the comment ID from WP_Query
$comment = get_comment( $comment_ID );
if (!empty($comment->comment_author) ) {
if($comment->user_id > 0){
$user=get_userdata($comment->user_id);
$author=$user->first_name.' '.substr($user->last_name,0,1).'.'; // this is the actual line you want to change
} else {
$author = mb_substr($user->first_name, 0, 1, 'UTF-8').'***'.' '.mb_substr($user->last_name, 0, 1, 'UTF-8');
}
} else {
$author = $comment->comment_author;
}
return $author;
}