Adding separator in User Profile Display Name

When you have set the User Display Name to Custom fields in wp-admin>Ultimate Member> Settings> General> Users. By default, the custom fields displayed in the profile form do not have any separator. See the sample image below.

Sample image:


To add a separator between fields, you need to use a custom code. You can try the sample code below:

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;
    }


Result: