Skip to:
Content
Pages
Categories
Search
Top
Bottom

If statement for latest activity

  • @buckybeever

    Participant

    Hi,

    I added some css (top and bottom border images) around the latest activity section of the member-header.php file… But you can see the added images if the member has not put up any activity.

    I’m guessing that I need an if statement to hide the images which are in divs in the header but I’m not sure how to write it properly…

    If someone could help me I would greatly appreciate it!

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

    Participant

    You should be able to simply take the ‘get’ function  and do an if( bp_get_last_activity( bp_displayed_user_id() ) to return a false/true result and wrap your markup in that

    @buckybeever

    Participant

    Thanks Hugo, can you show how to write it, sorry I’m a newbie

    @shanebp

    Moderator

    Use
    https://gist.github.com/
    to share your member-header.php file and put some notes in the area that you’re having trouble with.

    @buckybeever

    Participant

    Thanks added it here: https://gist.github.com/4290064

    @hnla

    Participant

    Think we were hoping to see what you had tried or were having trouble with. In that snippet of code it actually shows the principle of checking whether a function returns  true or false in the  line <code>if ( bp_is_active( ‘activity’ ) ) :</code>

    That line is saying if the activity component is active then render the code that follows it that ends just before the line ‘endif;’

    In a similar way <code> bp_get_activity_latest_update(bp_displayed_user_id())</code> will only be true if there is a latest update.

    To use the function as a check you need to wrap blocks of code in:

    if():

    endif;

     

    Have a go if you still get stuck edit that gist code snippet so we can see your workings and advise.

     

    N.B my earlier example function was incorrect  you need to use :

    <code>bp_get_activity_latest_update(bp_displayed_user_id())</code>

    @buckybeever

    Participant

    Thanks for your reply. I think I may be asking the wrong thing. I would like to hide everything in the divs if there isn’t any user latest activity posted, so I thought that if I used: if this, then show the divs, if not, then show nothing. But I dont know how to write it. Sorry for the confusion.

    @hnla

    Participant

    and that is exactly what is being explained – read through again. The if block  – that is the start of the if to the endif – wraps any content you wish to hide; it says if this function has data do something – if the function has no data then the if( has_some_data()  ) is the equivalent of false and thus anything inside the block will not be shown:

    thus:

    if ( bp_get_activity_latest_update ( bp_displayed_user_id() ) ) :

    show me stuff

    endif;

    will only show if there is activity data so wrap that around anything you don’t want to show if no data returned.

     

    Do give it a go best way of working things out is to experiment – on a local site copy naturally.

     

    @shanebp

    Moderator

    Untested, but try my amendment to your gist.

    https://gist.github.com/4290064

    btw – you really should have tried something like Hugo kept telling you. It’s okay to make mistakes and any effort you make will encourage others to help. Otherwise you risk falling into the do-this-for-me-for-free-and-do-it-now category of poster.

    @buckybeever

    Participant

    Hi, thanks shanebpx, I didn’t understand what Hugo was saying (I only know a very small amount of php), but now I can see from your post what he meant. Will try to figure it out. Thank you for all your help!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘If statement for latest activity’ is closed to new replies.
Skip to toolbar