• Resolved kgw203

    (@kgw203)


    does anyone know a way to show (by code probably) a user’s nicename (author slug NOT nickname) in the member directory card and profile pages?

    or maybe someone knows how to pull the user id for the “current” user shown in the member directory card. NOT um_profile_id(); this pulls current logged in user.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mykyta Synelnikov

    (@nsinelnikov)

    Hi @kgw203

    1. Could you clarify what did you mean by “author slug”? What is the usermeta key or column from the wp_users table used for that?
    2. Use user.id placeholder inside JS template inside templates/members-grid.php file for getting User ID (ID for the current user card).

    As soon as you provide the data about the author slug, I can reply about the place where you may replace the data.

    Let me know,
    Best Regards!

    Thread Starter kgw203

    (@kgw203)

    (thanks for the speedy response!)

    the column is user_nicename

    Plugin Author Mykyta Synelnikov

    (@nsinelnikov)

    Hi @kgw203

    Thanks for the details,

    1.Sorry for the formatting, I meant <code>user.id</code>

    2. Use this code snippet for adding user_nicename inside JSON data:
    You may insert it into the functions.php file in your theme/child-theme.

    function um_my_custom_ajax_get_members_data( $data_array, $user_id, $directory_data ) {
        $user_obj = get_userdata( $user_id );
        if ( false === $user_obj ) {
            return $data_array;
        }
        $data_array['nicename'] = $user_obj->user_nicename;
        return $data_array;
    }
    add_filter( 'um_ajax_get_members_data', 'um_my_custom_ajax_get_members_data', 10, 3 );

    Then edit your members-grid.php template file. https://www.screencast.com/t/2nvNyRXEp

    3. As an alternative way if you want to use nicename everywhere as display_name then please use this snippet inside your functions.php file.

    function um_my_custom_user_display_name_filter( $name, $user_id, $html ) {
        $user_obj = get_userdata( $user_id );
        if ( false === $user_obj ) {
            return $name;
        }
        $name = $user_obj->user_nicename;
        return $name;
    }
    add_filter( 'um_user_display_name_filter', 'um_my_custom_user_display_name_filter', 10, 3 );

    There is an article about templates overriding
    https://docs.ultimatemember.com/article/1516-templates-map

    Let me know if you have other questions,
    Best Regards!

    Thread Starter kgw203

    (@kgw203)

    This worked perfectly, thanks!
    I was also able to use hooks to add to the profile page.

    Thank you so much!
    Headache resolved.

    Plugin Author Mykyta Synelnikov

    (@nsinelnikov)

    Hi @kgw203

    Thanks for confirmed resolving! Hope this helps the community.

    Best Regards!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Display User NICENAME?’ is closed to new replies.