Please add new case to fep_user_name to include usermeta "last_name_suffix"


Home Forums Front End PM PRO Please add new case to fep_user_name to include usermeta "last_name_suffix"

This topic is: Not Resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14295
    Kyle Putnam
    Participant

    function fep_user_name( $id ){
    $which = apply_filters( ‘fep_filter_show_which_name’, ‘display_name’ );

    switch( $which ){

    case ‘first_last_name_suffix’:
    $name = fep_get_userdata( $id, ‘first_name’, ‘id’ ) . ‘ ‘ . fep_get_userdata( $id, ‘last_name’, ‘id’ ). ‘ ‘ . fep_get_userdata( $id, ‘last_name_suffix’, ‘id’ );
    break;

    case ‘first_last_name’:
    $name = fep_get_userdata( $id, ‘first_name’, ‘id’ ) . ‘ ‘ . fep_get_userdata( $id, ‘last_name’, ‘id’ );
    break;
    case ‘last_first_name’:
    $name = fep_get_userdata( $id, ‘last_name’, ‘id’ ) . ‘ ‘ . fep_get_userdata( $id, ‘first_name’, ‘id’ );
    break;
    case ‘first_name’:
    case ‘last_name’:
    case ‘user_login’:
    case ‘user_nicename’:
    $name = fep_get_userdata( $id, $which, ‘id’ );
    break;
    case ‘display_name’:
    default:
    $name = fep_get_userdata( $id, ‘display_name’, ‘id’ );
    break;
    }
    return apply_filters( ‘fep_filter_user_name’, $name, $id );
    }

    I have modified my FEP functions.php file to include this additional option and it is working perfectly. I would just like it incorporated into your code so it won’t get lost during updates. Thanks!

    #14298
    Shamim Hasan
    Keymaster

    Please do not change any plugin code. It will be overwritten when you update plugin.
    There are lots of hook in this plugin. So you can change almost anything without touching plugin code.
    To achieve this functionality without changing plugin code, please add following code in your theme’s ( child theme’s if any) functions.php

    add_filter( 'fep_filter_user_name', function( $name, $id ){
        $name = fep_get_userdata( $id, 'first_name', 'id' ) . ' ' . fep_get_userdata( $id, 'last_name', 'id' ) . ' ' . fep_get_userdata( $id, 'last_name_suffix', 'id' );
        return $name;
    }, 10, 2 );
Viewing 2 posts - 1 through 2 (of 2 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.