Skip to:
Content

BuddyPress.org

Opened 21 months ago

Last modified 20 months ago

#7652 new enhancement

Using template loop functions in a different (or no-loop context)

Reported by: DJPaul Owned by:
Milestone: Under Consideration Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

There have been a few tickets recently from people wanting to use template loop functions outside their respective template loop, and the suggestion has often been along the lines that function x should accept a user ID parameter so that it can be used.

I don't recall the most recent ticket this was discussed on, so I'm opening this one as a central ticket so we can make a decision if it's something we want to do, not do, or do on case-by-case basis. The perspectives of someone who's had to build a BuddyPress theme or customise an existing site's theme would be particularly useful input -- this might be a genuine pain point.

List of requests for this functionality:

  • #7640 - members loop - bp_get_send_public_message_link(), bp_get_send_private_message_link()

Change History (4)

#1 @antonioeatgoat
21 months ago

I build BuddyPress themes and I can say that it would be a pleasure for me to see those kind of functions working also out of the loop, receiving an user ID as parameter.
In my opinion it would just add flexibility to the BuddyPress functions, without lose anything.
Some of those functions are really useful and often I faced the need to use them out of a loop, however they con only be used with a kind of hack or not used at all.

#2 @DJPaul
20 months ago

@antonioeatgoat Thanks for sharing your feedback. Are you able to give just one or two examples of functions you use like this (or would like to), so I can look into it a bit more?

#3 @antonioeatgoat
20 months ago

@DJPaul for instance as I told in #7640, in a theme I tried to use the functions bp_get_send_public_message_link() and bp_get_send_private_message_link() in the header of the single member page, in order to provide quick links to public and private messages. However that functions don't accept the user id as parameter, so they weren't working there.

I'd have solved with something like these:

bp_get_send_public_message_button( array( 'link_href' => bp_get_send_public_message_link($user_id) ) );
bp_get_send_message_button( array( 'link_href' => bp_get_send_private_message_link($user_id) ) );

But those functions don't accept parameters at all. So at the end I had to solve with a kind of hack in using the filters inside the functions.

#4 @DJPaul
20 months ago

Thanks! Good argument so far.

Note: See TracTickets for help on using tickets.