BuddyDev

Search

[Resolved] Differentiation in hooks between own profile and other users profiles?

  • Participant
    Level: Guru
    Posts: 995
    calu on #33286

    Hi there, I have been looking at the available BP action hooks, and I wonder, why there are no differentiation and options in the hooks directory between own profile and other users profiles?

    An example is the hookbp_after_profile_contentwhich displays on all profiles. I’m inserting the hook in an block element with no options for adding extra code for own profile.

    Is it possible to add something to the existing hooks, for specifying own or other users profiles?

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 21856
    Brajesh Singh on #33293

    Hi Carsten,
    The hooks will remain same.
    You can use a function like

    
    if ( bp_is_my_profile() ) {
    // my profile.
    } else {
    	// not my profile.
    }
    

    For hooks which only run on profile.

    If you want to hook to a general action which may run on other pages and you want to do something for own profile/other profile.

    You can do it like this

    
    
    if ( bp_is_my_profile() ) {
    // my profile.
    } elseif ( bp_is_user() ) {
    	// not my profile. but is guaranteed to be another user's
    }
    
    

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 995
    calu on #33298

    Hi Brajesh, thanks for the codes, unfortunately the Block Elements from the theme I’m using will not accept PHP, but the codes are good to know anyway.

    Regards
    Carsten

You must be logged in to reply to this topic.

This topic is: resolved