Skip to:
Content

BuddyPress.org

Opened 7 years ago

Closed 10 months ago

#7652 closed enhancement (maybelater)

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

Reported by: djpaul's profile DJPaul Owned by:
Milestone: 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 (5)

#1 @antonioeatgoat
7 years 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
7 years 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
7 years 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
7 years ago

Thanks! Good argument so far.

#5 @espellcaste
10 months ago

  • Milestone Under Consideration deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.