これは私がやろうとしていることです。私はプラグインに取り組んでおり、それぞれのコメントをチェックして、そのコメントの作成者が「管理者」または「エディタ」の役割を持っているかどうかを確認したい。彼らがユーザー名とアバターを表示するのではなく、会社のロゴなどと一緒にウェブサイトの名前を表示したいと考えています。私は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');
お世話になりました、ありがとうございました。私は役割をチェックしなければなりません、ユーザ名は変更され、他は追加されます。私はチェックする必要がある2つの異なる役割を持っています: "エディタ"、 "管理者"。また、私はどこに引っ掛けるだろうか?私はフィルターを使いますか? – jared10222