그래서 여기에 내가하려고하는 것이있다. 나는 플러그인을 작성 중이고 각 주석을 확인하고 해당 주석의 작성자가 "관리자"또는 "편집자"역할을하는지 확인하려고합니다. 사용자 이름과 아바타를 표시하는 대신 웹 사이트의 이름과 회사 로고 등을 표시하고 싶습니다. 나는 WordPress 개발에 익숙하지 않아이 문제에 집착하고있다. 이 필터가 있는지 또는 사용자 지정 메모 서식 파일을 만들어야하는지 알 수 없습니다. 누군가가 나를 올바른 방향으로 향하게 할 수 있다면 그것은 좋을 것입니다. 왜냐하면이 시점에서 나는 어디에서 시작해야할지 모르겠습니다. 고맙습니다.특정 역할과 일치하는 경우 사용자 이름을 주석의 사이트 이름으로 표시하십시오. wordpress
내가, 내 생각 과정 : 주석을 표시 할 때
<?php
function anonymize_author(){
global $post;
//get the id of the comment author
$author_id = $post->post_author;
//get the userdata of comment author
$author_info = get_userdata($author_id);
//get the user roles of comment author
$author_roles = $author_info->roles;
//Array of roles to check against
$roles_to_check = ["editor", "administrator"];
//see if user has a role in my $roles_to_check array
$results = array_intersect($roles_to_check, $author_roles);
if(!empty($results)){
//the user has roles of either "editor" or "administrator"
//load custom comments page?
//I need to display the author name as the site name
//and the avatar as the site logo
}else{
//Just a regular user, load the Wordpress Default comments
}
}
add_filter('some_filter_here', 'anonymize_author');
안녕하세요 Dolatabadi, 응답 해 주셔서 감사합니다. 역할을 확인해야하며 사용자 이름이 변경되고 다른 사용자 이름이 추가됩니다. 내가 확인해야 할 2 가지 역할이 있습니다 : "편집자", "관리자". 또한, 나는 어디에서 훅을 걸 것이냐? 필터를 사용합니까? – jared10222