Opened 9 years ago
Closed 5 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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 10.0.0 |
| Component: | Messages | Version: | |
| Severity: | normal | 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
@
9 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
@
9 years ago
I will try to convert it to a patch and show a screenshot , after my holidays, thanks
@
9 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
@
9 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
@
9 years ago
- Milestone Future Release → 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
@
8 years ago
- Keywords good-first-bug removed
- Milestone Under Consideration → Awaiting Contributions
Given no-one else has expressed a view, in principle, I think this is a good idea to have.
#8
@
7 years ago
- Owner set to
- Status new → assigned
Hi,
I agree, I'm going to see how to include this into the Nouveau template pack.
#9
@
5 years ago
- Keywords needs-refresh added; has-patch removed
- Milestone Awaiting Contributions → 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.
5 years ago
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
5 years ago
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
5 years ago
#13
@
5 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!
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@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.