WooCommerce Review ID Block – WordPress Development Stack Exchange

Question

add_filter(‘get_comment_author’, ‘my_comment_author’, 10, 1);

function asterisk($num){
$arr = array();
for ($i = 1; $i <= $num; $i++) {
array_push($arr,”*”);
}
return $arr;
}
function customerName($cName){
$name = $cName;

$explode_name = explode(” “, $name);
$fname = $explode_name[0];

$count_fname = strlen($fname);

$count_fname = 1 – $count_fname;
$count_fname = abs($count_fname);
$asterisk = implode(“”,asterisk($count_fname));
$final = “$fname[0] $asterisk”;

return $final;
}
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 = $comment->comment_author;
}

return customerName($author);
}

////////////////////////////////
What I want to do is expose only the first letter of the review ID and cover the rest with *. In WooCommerce, the ID is basically set to be exposed, but please let me know if there is a code that exposes only the first letter of the ID and covers the rest with *. I really, really need help.

0
Jisoo Lee 2 months 2023-02-01T22:04:03-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse