Opened 7 years ago
Closed 3 years ago
#7540 closed enhancement (fixed)
Adding a button and function for a member to leave a multi-recipients conversation
Reported by: | Oelita | Owned by: | imath |
---|---|---|---|
Milestone: | 10.0.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Messages | Keywords: | ux-feedback needs-refresh |
Cc: |
Description
I had a client request to add a button and function for members on their message page, when they are in a multi recipients conversation, to quit. They don't want to receive all the answers of this thread anymore.
I searched and find nothing to be able to do that. If you delete the message, you're still part of the reciepients, and receive further answers.
So I coded to do that, and wonder if this could be an enhancement feature. Here is my code so far :
my theme part :
<?php function lg_get_first_message($thread_id) { global $wpdb; $bp = buddypress(); $message_id = (int) $wpdb->get_var( "SELECT MIN(id) FROM {$bp->messages->table_name_messages} WHERE thread_id = $thread_id" ) ; return intval($message_id); } function lg_get_thread_from($thread_id) { $message_id = lg_get_first_message($thread_id); $sender_id = messages_get_message_sender($message_id); return intval($sender_id); } function lg_messages_action_quit_message() { if ( ! bp_is_messages_component() || !bp_is_current_action( 'quit' ) ) { return false; } $thread_id = bp_action_variable(0); if ( !$thread_id || !is_numeric( $thread_id ) || !messages_check_thread_access( $thread_id ) ) { bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/view' ) ); } else { global $wpdb, $bp; $thread = new BP_Messages_Thread( $thread_id ); if ( count( $thread->recipients ) > 2 and lg_get_thread_from($thread_id) != bp_loggedin_user_id() ) { $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) ); wp_cache_delete( "thread_recipients_{$thread_id}", 'bp_messages' ); } bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/inbox' ) ); } } add_action( 'bp_actions', 'lg_messages_action_quit_message' ); ?>
template part, in \members\single\messages\single.php, after the Delete conversation button :
<?php $thread = new BP_Messages_Thread( bp_get_the_thread_id() ); if ( bp_get_thread_recipients_count() > 2 and bp_loggedin_user_id() != lg_get_thread_from(bp_get_the_thread_id()) ) : ?> <a class="button confirm" href="<?php echo trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/quit/' . bp_get_the_thread_id() ); ?>"><?php _e( 'Quit conversation', 'buddypress' ); ?></a> <?php endif;
Attachments (10)
Change History (25)
#2
@
7 years ago
- Keywords good-first-bug ux-feedback added
I don't recall doing this myself. I do recall talking with @Oelita at WCEU about this feature.
The above could probably be converted to a patch without too much trouble. It would be helpful to see screenshots of what the UI mods look like, especially with respect to Nouveau.
#3
@
7 years ago
I will try to convert it to a patch and show a screenshot , after my holidays, thanks
@
7 years ago
UI in bp-default : added button (showed in orange). NB : message showing recipients is wrong, the final "and you" should be removed ? (underlined in blue)
#4
@
7 years ago
NB : Oups, I forgot to underline the "and you" in blue in my screenshot.
I tried to follow the structure of BP code, this is my first real code for BP, please tell me if I didn't make it in the right way.
#6
@
7 years ago
- Milestone changed from Future Release to Under Consideration
Let's consider if we want this feature, where we are at with it based on the historic patches, and how it might integrate into Nouveau.
#7
@
7 years ago
- Keywords good-first-bug removed
- Milestone changed from Under Consideration to Awaiting Contributions
Given no-one else has expressed a view, in principle, I think this is a good idea to have.
#8
@
5 years ago
- Owner set to imath
- Status changed from new to assigned
Hi,
I agree, I'm going to see how to include this into the Nouveau template pack.
#9
@
3 years ago
- Keywords needs-refresh added; has-patch removed
- Milestone changed from Awaiting Contributions to 10.0.0
I've been playing around with messages lately. I actually think it's a must have currently when you delete a thread, if one of the recipients add a reply the thread is back so it can be very confusing. I believe this "Quit conversation" will actually be the best way to stop receiving messages/notifications about a thread.
Let's finally have this in before the end of the 10.0.0 dev cycle.
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
3 years ago
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
3 years ago
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
3 years ago
#13
@
3 years ago
Thanks for your patch @vapvarun ! It looks solid after a first sight, Screenshots are looking very promising. I'll try to test and review before tomorrow's dev chat!
@boonebgorges was it you who did something around this a while ago? I think I recall a Slack conversation, but I can't remember the details.