&display=swap
وردپرس

نام نمایشی دلخواه بر اساس نقش کاربری


سلام
من با این کد نقش کاربری رو در کنار نام تو قسمت نظرات سایتم قرار دادم اما مشکل اینه میخوام نام نمایشی دلخواه به فارسی قرا بگیره
مثلا administrator رو به فارسی ” مدیر ” نشون بده

نام نمایشی دلخواه بر اساس نقش کاربری
نام نمایشی دلخواه بر اساس نقش کاربری
/** Add User Role to Comments. */
if ( ! class_exists( 'Comment_Author_Role_Label' ) ) :
class Comment_Author_Role_Label {
public function __construct() {
add_filter( 'get_comment_author', array( $this, 'get_comment_author_role' ), 10, 3 );
add_filter( 'get_comment_author_link', array( $this, 'comment_author_role' ) );
}
function get_comment_author_role($author, $comment_id, $comment) {
$authoremail = get_comment_author_email( $comment);
if (email_exists($authoremail)) {
$commet_user_role = get_user_by( 'email', $authoremail );
$comment_user_role = $commet_user_role->roles[0];
$this->comment_user_role=" " . ucfirst($comment_user_role) . '';
} else {
$this->comment_user_role="";
}
return $author;
}
function comment_author_role($author) {
return $author .= $this->comment_user_role;
}
}
new Comment_Author_Role_Label;
endif;

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا