Skip to:
Content
Pages
Categories
Search
Top
Bottom

Make a different profile page for a special user


  • imjscn
    Participant

    @imjscn

    I want to do this on the header of profile page—
    if user ID is 1 or 2, display
    ABC

    instead of
    “last update’, “mention this user”….

    if user is anybody else, display item-meta as normal.

    How to do this?

    in members-header.php, can comment out a line to display some fields, but that changes for all. I want to change for only several member’s profile page.

Viewing 14 replies - 1 through 14 (of 14 total)
  • It’s essentially already being done, if you look at member-header.php you will see that ‘last activity’ and ‘latest updates’ for the member being displayed are fetched by passing in bp_displayed_user_id() that function returns the current displayed user so all you need to do is an if displayed user == ‘ID’ do some stuff else carry on and do latest update.


    imjscn
    Participant

    @imjscn

    @hnla, I searched around, still can’t figure out how to write down the code, would you help me settle down this code?
    if displayed user ==”ID”, do this, else, carry on as normal.

    What did you actually try though Jenny?

    For each profile display in the header.php there is the function:

    bp_displayed_user_id()

    This always returns the id of the current profile or user that is being viewed, you can check that by simply adding above the heading tag:

    <?php echo bp_displayed_user_id() ?>

    And you should see a numeric value returned which is that members ID

    Now we know that it’s a simple case of writing an if conditional that carries as it’s primary query:

    bp_displayed_user_id() == 1

    If you’re not sure how to write PHP conditionals look through various theme files as there are countless examples of them (you’ll spot them by the fact they start with ‘if’ ) or check out the PHP docs php.net or google ‘php conditional statements’

    If you are really still stuck post back and we’ll help further but conditionals are a useful bit of PHP coding to learn to write


    imjscn
    Participant

    @imjscn

    Thanks! I will try to manage, and come back later


    imjscn
    Participant

    @imjscn

    @hnla, I think the problem is the things after “endif”.
    I added if bp_displayed_user_id() == 1 , display this, endif, so, after displayed user 1 stuffs, other things after the endif still carry out.
    I want to remove things after the endif when userid is 1.


    Roger Coathup
    Participant

    @rogercoathup

    @imjscn

    You need to put that code you don’t want for user 1 in an ‘else’ clause then.

    If you are working with the template code in this way, you should really read up on PHP. A simple primer on the language will take you through these basic constructs in no time.


    Roger Coathup
    Participant

    @rogercoathup


    Boone Gorges
    Keymaster

    @boonebgorges

    For what it’s worth, Paul’s awesome snufflewufflepants patch will make this easier in BP 1.3 https://trac.buddypress.org/ticket/2649

    In the meantime, hnla and Roger’s advice is good.

    No patch can be allowed to be committed called snufflewuffwafflepants, sorry!

    Still will always be a need for basic frontend PHP manipulation though, especially of the conditional construct variety.


    imjscn
    Participant

    @imjscn

    Thanks, @Boone Gorges, but creating a template will be a even more complicated project for me. Iet me try the would-be-simple way first.
    @Roger, @hnla, thanks! but I need more details to get the job done.
    Would you please help me check what’s wrong with the following code? the stuffs in the else { } still gets loaded in this user’s profile:
    `

    `

    `

    ….

    `
    `else{ original code }`

    `

    `

    You’r5e mixing different syntax approaches to writing a conditional:

    Classic is:
    {
    }

    generally used though is :

    so your else needs to be

    <?php else: ?>

    ‘stuff here’

    <?php endif; ?>


    imjscn
    Participant

    @imjscn

    @hnla, can’t see your code. you need sorround every line with backticks.
    Sorry, I just edited previous post. the error message was because an unexpected “:”, I changed it, the error message gone.
    Now the if statement gets all stuffs loaded after the special user’s content, and all other user’s item header become blank. — the reverse result.

    oops forgot to escape the entities, little bit busy at the moment.

    <?php else: ?>


    imjscn
    Participant

    @imjscn

    @hnla, thanks a million! It works finally!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Make a different profile page for a special user’ is closed to new replies.
Skip to toolbar