Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Display user id


  • razman
    Participant

    @razman-wan-fatul

    Hi, I’m trying to display user id number in the frontend, at both profile page and members list page. I’ve been searching the forum, the only answer I found was bp_displayed_user_id() without further explanation. Can anyone guide me on how to achieve this with detail explanation? I tried putting <?php bp_displayed_user_id(); ?> in member-header.php but no success. Appreciate your help!

Viewing 2 replies - 1 through 2 (of 2 total)

  • danbp
    Moderator

    @danbp

    Hi,

    you need a function to do that.

    Here’s one who will show the user id on profile header and on members directory.
    Add it to bp-custom.php or child theme functions.php

    function razman_user_id_display() {
    	if ( bp_is_user() ) {
    		$user_id = bp_displayed_user_id();	
    	} else {
    		$user_id = bp_get_member_user_id();
    	}
    		
    	echo '<div class="myuser-id">My user ID: '. $user_id .'</div>';
    	
    }
    add_action( 'bp_before_member_header_meta', 'razman_user_id_display' );
    add_action( 'bp_directory_members_item', 'razman_user_id_display' );

    razman
    Participant

    @razman-wan-fatul

    Thank you @danbp, works like a charm!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Display user id’ is closed to new replies.
Skip to toolbar