• Resolved nxite

    (@nxite)


    Dear community!

    I very much hope for your knowledge, unfortunately I’m standing in line with my knowledge.

    I tried to add a separator to Ultimate Member > General > Users under “Show custom name field(s)”:

    company_name | first_name last_name

    Unfortunately, these meta’s appear without this separator “|”. (Currently I have added this separator manually to each member, which unfortunately is not a solution for the future).

    Do you have any idea how I can include a separator between the company name and the first and last name?

    Thank you so much!

    Best wishes
    Rebecca

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • @nxite

    You can try this code snippet:

    add_filter( 'um_user_display_name_filter', 'my_um_user_display_name_filter', 10, 3 );
    
        function my_um_user_display_name_filter( $name, $user_id, $attrs ) {
    
            if( $attrs == 1 ) {
                $name = um_user( 'company_name' ) . ' | ' . um_user( 'first_name' ) . ' ' . um_user( 'last_name' );
            }
            return $name;
        }

    Add the code snippet to your child-theme functions.php file

    or use the “Code Snippets” Plugin: https://www.ads-software.com/plugins/code-snippets/

    • This reply was modified 2 years, 9 months ago by missveronica.
    • This reply was modified 2 years, 9 months ago by missveronica.
    Thread Starter nxite

    (@nxite)

    Thank you so much @missveronicatv ! ??

    I only had to make a small change, otherwise it threw a syntax error:

    add_filter( ‘um_user_display_name_filter’, ‘my_um_user_display_name_filter’, 10, 3 );

    function my_um_user_display_name_filter( $name, $user_id, $attrs ) {

    //if( um_profile_id() == $user_id && $attrs == 1 ) {
    $name = um_user( ‘company_name’ ) . ‘ | ‘ . um_user( ‘first_name’ ) . ‘ ‘ . um_user( ‘last_name’ );
    //}
    return $name;
    }

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know how it resolve the issue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Name field with separator’ is closed to new replies.