First name for member dashboard in place of username

Discussion in 'Customization & add-ons' started by siteprowizard, Jan 16, 2017.

  1. siteprowizard

    siteprowizard New Member

    Joined:
    Dec 5, 2016
    Messages:
    1
    I asked this question via support...
    where do i access or how can i change it so that the first name displays on the member dashboard instead of the username?

    and was given this code to add to the site.php file - but it causes the page to be blank
    --------------------------------

    Am_Di::getInstance()->blocks->remove('member-identity');
    Am_Di::getInstance()->blocks->add(new Am_Block('member/identity', null, 'member-identity-custom', null,
    function(Am_View $v){
    $name = Am_Html::escape($v->di->user->getName());
    $url = Am_Di::getInstance()->url('logout');
    $url_label = Am_Html::escape(___('Logout'));
    return <<<CUT
    <div class="am-user-identity-block">
    $name <a href="$url">$url_label</a>
    </div>
    CUT;
    }));

    ----------------------

    need some help with this
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    The code is correct but it rely on feature that is not exists in current version.
    So change it to:
    PHP:
    Am_Di::getInstance()->blocks->remove('member-identity');
    Am_Di::getInstance()->blocks->add(new Am_Block('member/identity'null'member-identity-custom'null,
        function(
    Am_View $v){
                    
    $name Am_Html::escape($v->di->user->getName());
                    
    $url REL_ROOT_URL '/logout';
                    
    $url_label Am_Html::escape(___('Logout'));
                    return <<<CUT
    <div class="am-user-identity-block">
        
    $name <a href="$url">$url_label</a>
    </div>
    CUT;
                }));
  3. halmaclean

    halmaclean aMember Pro Customer

    Joined:
    Aug 30, 2013
    Messages:
    50
    This has all moved on a bit since the original post, so apologies if I am a bit late to the party.

    If you switch your theme to 'Solid Color' then you get the ability to change this as part of the appearance configuration, giving you access to Name, email or username for the identity block, plus altering the position of it.

    Pretty sure you'll have discovered that by now, so I'm just posting this here for future reference.

    upload_2021-9-15_13-39-55.png
    caesar likes this.
  4. everbatim

    everbatim aMember Pro Customer

    Joined:
    Dec 19, 2007
    Messages:
    65
    Thanks for this info. Any idea on how to make this work with custom themes? I assume it is just the inclusion of some codes in one of the phtml template files? Thanks!
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    @everbatim you can find it in template file:
    application/default/views/blocks/member-identity-std.phtml
    and do necessary adjustment in your theme.
    halmaclean likes this.

Share This Page