Skip to:
Content

BuddyPress.org

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#7851 closed defect (bug) (fixed)

Alternative hook to bp_messages_inbox_list_item that can be used with BP Nouveau

Reported by: pareshradadiya Owned by: imath
Milestone: 3.1.0 Priority: normal
Severity: normal Version:
Component: Templates Keywords: has-patch commit
Cc:

Description

I use bp_messages_inbox_list_item to add <td> in messages list on Inbox page.

The bp_before_member_messages_loop callback function does not works when BP Nouveau template pack is enabled.

Here the code snippets of my use case:

<?php
add_action( 'bp_messages_inbox_list_item', 'test_message_inbox_list_item' );

function test_message_inbox_list_item() {
        global $messages_template;
        $thread_id = isset( $messages_template->thread->thread_id ) && !empty( $messages_template->thread->thread_id ) ? $messages_template->thread->thread_id : '';

        if ( !empty( $thread_id ) ) {
                $get_thread_data = test_get_message_data( $thread_id );
        }

        // ...more custom code
}

It would be great if BP Nouveau add similar hook that allow plugin developer hook custom function to show custom content in messages list.

Attachments (2)

7851.patch (8.1 KB) - added by imath 2 years ago.
7851.2.patch (6.3 KB) - added by imath 2 years ago.

Download all attachments as: .zip

Change History (15)

#1 @imath
2 years ago

Thanks for your feedback. In Nouveau we do not use a table anymore but I understand the need, to maintain this level of customization in Nouveau we need to have a more granular approach about JS Templates i think.

#2 @DJPaul
2 years ago

  • Milestone changed from Awaiting Review to 3.0.1

#3 @imath
2 years ago

  • Owner set to imath
  • Status changed from new to assigned

#4 @DJPaul
2 years ago

  • Milestone changed from 3.0.1 to 3.1.0

Milestone renamed

#5 @imath
2 years ago

  • Keywords reporter-feedback 2nd-opinion added

@pareshradadiya After a deeper look and to be consistent with the choices we've made about the star/unstar action button, I think it's best to move the content you want to add into the new "Active Conversation" preview box so that we keep this messages list as simple as possible.

I'm suggesting the areas with red border I added to this screen capture :

https://cldup.com/7TtKU204wI.png

The first one could be used to add a button just like we're doing for the star/unstar action. And the second one could be a <table> to display the tds plugin are adding using this bp_messages_inbox_list_item hook.

@pareshradadiya && @hnla what do you think of this alternative ?

@imath
2 years ago

#6 @imath
2 years ago

7851.patch is doing what i've described above and introduces a new function to register Messages meta bp_messages_register_meta(). This is needed to know what meta data to fetch. As @r-a-y played with messages meta with the Star feature, his opinion is very welcome :)

You'll need to apply 7847.3 & (probably) 7850.2 patches before this one to test

Last edited 2 years ago by imath (previous) (diff)

#7 @imath
2 years ago

  • Keywords has-patch added

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


2 years ago

#9 @imath
2 years ago

  • Keywords needs-refresh added; reporter-feedback 2nd-opinion removed

After giving this ticket some more thoughts, I think introducing a function like bp_messages_register_meta() in a minor release is not a good idea. I'll probably open a discussion about this kind of function into a new ticket for a future major release. For now i'm going to update the patch asap to only keep the part about adding custom content under the message content of the Active conversation preview.

@imath
2 years ago

#10 @imath
2 years ago

  • Keywords commit added; needs-refresh removed

Working on 7851.2.patch, I've found there were a legacy hook to allow developers to add content before and after the message meta. I've added these 2 hooks to the "Ajax caught ones".

Last edited 2 years ago by imath (previous) (diff)

#11 @imath
2 years ago

In 12141:

Messages: catch Legacy hooks to customize the Active conversation box.

In order to preserve in the BP Nouveau Messages UI the level of PHP customization that developers are used to get in Legacy using do_action hooks, The content generated for the following hooks will be caught during Ajax requests and added as new properties of their JSON replies:

  • bp_before_message_meta
  • bp_after_message_meta
  • bp_messages_inbox_list_item
  • bp_messages_thread_options

About the bp_messages_inbox_list_item hook: as the Messages UI of BP Nouveau, unlike Legacy, is not using a table tag to display the list of messages received/starred/sent. All extra actions about messages into these loop views are done within the Active conversation box (eg: star/unstar). To inject the content of this specific hook, we are adding a table element under the message content preview as the expected output is a td tag.

See #7851 (Trunk)

#12 @imath
2 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 12142:

Messages: catch Legacy hooks to customize the Active conversation box.

In order to preserve in the BP Nouveau Messages UI the level of PHP customization that developers are used to get in Legacy using do_action hooks, The content generated for the following hooks will be caught during Ajax requests and added as new properties of their JSON replies:

  • bp_before_message_meta
  • bp_after_message_meta
  • bp_messages_inbox_list_item
  • bp_messages_thread_options

About the bp_messages_inbox_list_item hook: as the Messages UI of BP Nouveau, unlike Legacy, is not using a table tag to display the list of messages received/starred/sent. All extra actions about messages into these loop views are done within the Active conversation box (eg: star/unstar). To inject the content of this specific hook, we are adding a table element under the message content preview as the expected output is a td tag.

Fixes #7851 (Branch 3.0)

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


2 years ago

Note: See TracTickets for help on using tickets.