Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Display a membership number

  • @csimpson

    Participant

    hi there everyone, i would like to assign and display a unique user id number on a members profile page. I want each member to have a unique id (incremental) to make communication easier for admins.

    Any ideas most welcome, however, to date ive seen alot of references to using the wordpress default user id. if this seems a good solution, how do i display this on a users profile page for the user and the admin to see.

    Ideally, i dont want to start at id number 1 or 000001.

    i can’t believe i cannot already find an answer to this. 🙁
    best wishes Craig

Viewing 9 replies - 1 through 9 (of 9 total)
  • @henrywright

    Moderator

    <?php bp_displayed_user_id(); ?> will work on the member’s profile page.

    @csimpson

    Participant

    Hi thanks, any idea which file to add this too. I’ve tried many files with no success for other aspects. Many thanks. This is a starting point if no other suggestions arise. I thought a membership I’d would have been a popular thing to do.

    @henrywright

    Moderator

    bp_displayed_user_id() is the member’s ID so perhaps that’s the same as a membership ID? I’m not sure it matters though as the important part is it’s a unique identifier so whatever name we give it is irrelevant.

    You should be able to add it to your member-header.php file. Which theme are you using? Some themes might not have it so you’ll need to create it yourself if that’s the case. It might be worth reading up on the Template Hierarchy to get a feel of how BuddyPress templates work.

    @shanebp

    Moderator

    afaik – bp_displayed_user_id() requires an echo for display.

    So in your template overload of this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\single\member-header.php

    paste: echo bp_displayed_user_id();

    @henrywright

    Moderator

    bp_displayed_user_id() requires an echo for display.

    Just to confuse us all! 😉

    @csimpson

    Participant

    hi again! thanks for comments i got this to display the number perfectly.

    my only issue was getting past starting the numbers at 1, then 2, 3, 4 etc – default ids.

    I though if i edited the last user id in database core to something like 3111, then the next would be 3112, and so on. But i had no luck, it just resumed where it left off in terms of member number.

    any thoughts friends out there? regards Craig

    @henrywright

    Moderator

    I wouldn’t advise editing the user IDs in the database as I have no idea what would happen when WordPress wants to allocate an ID to the next newest member and you’ve already used that particular ID.

    Which number would you like to start at? If it’s not very big then you could always create some dummy users yourself which would take up the first few IDs? Once real users begin to sign up you can delete the dummy users. To my knowledge, the dummy user IDs won’t get recycled.

    @csimpson

    Participant

    the purpose is too hide the obvious lack of members from the start, so id like to start at something like 3212, then it increments upwards

    @henrywright

    Moderator

    You could do this:

    echo '100' . bp_displayed_user_id();

    So, if the value of bp_displayed_user_id() was 1, then 1001 would be echo’d on screen.

    That said, I don’t see anything wrong in starting at 1. There’s no shame in being a brand new website. Everyone started at zero, even Facebook

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Display a membership number’ is closed to new replies.
Skip to toolbar