Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change mentionname to displayname in “cover-image-header.php”


  • richard.miller
    Participant

    @richardmiller-1

    I have a child theme, and am attempting to change the mention name (the “@” user name) to the display name (full name, first and last).

    Looks like this is the place to do it:
    buddypress\members\single\cover-image-header.php

    And this looks like the line to edit:
    <h2 class=”user-nicename”>@<?php bp_displayed_user_mentionname(); ?></h2>

    I’ve changed the “mentionname” in that line to “displayname”, but it breaks the page.

    What should I be using, and in the future, where should I look for this kind of answer?

Viewing 3 replies - 1 through 3 (of 3 total)

  • richard.miller
    Participant

    @richardmiller-1

    And as long as we’re in this template, how/where can I get rid of the title of these pages?

    Shows up like this at the top of the page:

    <h1 class=”entry-title main_title”>First Last</h1>


    richard.miller
    Participant

    @richardmiller-1

    Bump?


    Boone Gorges
    Keymaster

    @boonebgorges

    Hi @richardmiller-1 – The purpose of the @username part of the interface is to tell other users how to mention the user when posting new activity items, etc. It’s possible to change the value that’s displayed here, but if you do, and if users then use that text to “mention” others, then things like auto-linking of @-mentions and @-mention notifications will break, since BP doesn’t know by default how to search by display names.

    If you just want to change the display, then you should copy the cover-image-header.php template to your own child theme, and then change the line you’ve referenced to:

    
    <h2 class=”user-nicename”>@<?php echo bp_core_get_user_displayname( bp_displayed_user-id() ); ?></h2>
    

    It might be possible to retool some of the @-mention plumbing so that notifications etc work. You’d want to start by filtering bp_activity_mentioned_users(), and copying some of the logic in bp_activity_find_mentions() but with modified regex + user lookup. (This is going to be hard because, among other things, display names are not necessarily unique across a network, so @Richard could refer to multiple people. But that depends on the nature of your network.)

    The h1 at the top of the profile page is generated in a weird way, as part of BP’s theme compatibility system. It’s not directly generated by BP, but comes from your WP theme; BP is faking the theme into thinking that the user’s display name is the title of the WP page, so that your theme’s page.php template outputs it as the_title(). There are various workarounds for this. One is to tap into BP’s template hierarchy, so that WP would use a separate template file for single member pages. See https://codex.buddypress.org/themes/theme-compatibility-1-7/template-hierarchy/#single-member-pages for details. Basically, you’d copy page.php to buddypress/members/single/index.php, and remove the call to the_title(). A simpler solution is to hide with CSS:

    
    .bp-user .entry-title {
    	display: none;
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar