• 作成者の画像を消して、ユーザー名のプロフィールリンクを無くして、シンプルにユーザー名だけにしたいです。

    どこを修正したり、削除すればいいのでしょうか?

    宜しくお願いします。

3件の返信を表示中 - 1 - 3件目 (全3件中)
  • テーマ用のテンプレートの定義ファイル、例えば bbpress/templates/default/bbpress/loop-single-forum.php を読むと、次のようなコードがありました。

    <?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?>

    この関数 bbp_author_link の中で、作成者の画像やユーザー名のプロフィールリンクを出力しているようなので、それを削除すれば良さそうでした。

    関数 bbp_author_link の定義を探すと、プラグインのファイル bbpress/includes/users/template.php にありました。

    function bbp_author_link( $args = '' ) {
    echo bbp_get_author_link( $args );
    }

    同じファイルに関数 bbp_get_author_link の定義もあり、それを読むと、この関数自体で出力する他に、関数 bbp_get_topic_author_link または bbp_get_reply_author_link の何れかに任せて出力してもらう場合がありました。

    そこで、3つの関数それぞれを変更して、画像とリンクの出力を無くす検証を行ってみました。以下、その内容です。

    bbp_get_author_link の場合は、まずアバターを出力する下記の行をコメントアウト。

    // $author_links[] = get_avatar( $user_id, $r['size'] );

    それから、<a>タグを埋め込む下記の行をコメントアウトして

    // $author_link[] = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text );

    次のように変えて埋め込ませないようにしました。

    $author_link[] = $link_text;

    次に bbp_get_topic_author_link はファイル bbpress/includes/topics/template.php にありました。変更は先ほどと同様に

    // $author_links['avatar'] = bbp_get_topic_author_avatar( $topic_id, $r['size'] );

    それから

    // $author_link[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, $link_class, $link_text );
    $author_link[] = $link_text;

    最後に bbp_get_reply_author_link はファイル bbpress/includes/replies/template.php にあり、変更は同様に

    // $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] );

    それから

    // $author_link[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, $link_class, $link_text );
    $author_link[] = $link_text;

    なお、私はプラグインのphpファイルを直接書き換えて試しましたが、bbpressプラグインのバージョンアップにより元に戻ってしまわないようにフィルターを使って同様の変更を行った方がよいと思います。3つの関数それぞれに、関数名と同じ名前のフィルター(bbp_get_author_link, bbp_get_topic_author_link, bbp_get_reply_author_link)が用意されていました。

    Examples:

    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => false, 'type' => 'name' ) ); ?>
    “Displays only the current reply author user’s display name without their avatar or user role” via http://codex.bbpress.org/bbp_reply_author_link/

    <?php bbp_topic_author_link( array( 'sep' => '<br />', 'show_role' => false, 'type' => 'name' ) ); ?>
    “Displays only the current topic author user’s display name without their avatar or user role” via http://codex.bbpress.org/bbp_topic_author_link/

    More examples are at each of the following links:
    http://codex.bbpress.org/bbp_author_link/
    http://codex.bbpress.org/bbp_reply_author_link/
    http://codex.bbpress.org/bbp_topic_author_link/

    Hope it helps 🙂

    トピック投稿者 yca

    (@yca)

    かなり時間が経過しKeymasterていますが、リンクもなくなり画像も消えましたが、”bbp-author-role”のKeymasterなども消したいです。

    あと、ユーザー名の位置(高さ)を調整するにはどうしたらいいでしょうか?

    宜しくお願いします。

3件の返信を表示中 - 1 - 3件目 (全3件中)

トピック「bbpressの作成者などを変更したい」には新たに返信することはできません。