Skip to:
Content

BuddyPress.org

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's profile Oelita Owned by: imath's profile 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)

patch7540.diff (6.1 KB) - added by Oelita 7 years ago.
Patch for BuddyPress adding functions needed
patch7540bpdefault.diff (852 bytes) - added by Oelita 7 years ago.
Patch for theme bp-default for using functions added
quitconversation.jpg (32.1 KB) - added by Oelita 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)
7540-1.patch (57.0 KB) - added by vapvarun 3 years ago.
Initial Patch
7540-2.patch (56.9 KB) - added by vapvarun 3 years ago.
update file name and fixed spelling mistake
quit conversation.png (189.9 KB) - added by vapvarun 3 years ago.
screenshot with bp-nouveau
7540-3.patch (55.4 KB) - added by vapvarun 3 years ago.
micro fixes in initial patch
after leaving conversation.png (121.1 KB) - added by vapvarun 3 years ago.
screenshot with bp-nouveau after leaving conversation
Legacy Quit Conversation.png (165.0 KB) - added by vapvarun 3 years ago.
legacy quit conversation
7540-4.patch (56.8 KB) - added by vapvarun 3 years ago.
updated with missing new file

Download all attachments as: .zip

Change History (25)

#1 @DJPaul
7 years ago

  • Milestone changed from Awaiting Review to Future Release

@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.

#2 @boonebgorges
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 @Oelita
7 years ago

I will try to convert it to a patch and show a screenshot , after my holidays, thanks

@Oelita
7 years ago

Patch for BuddyPress adding functions needed

@Oelita
7 years ago

Patch for theme bp-default for using functions added

@Oelita
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 @Oelita
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.

#5 @Oelita
7 years ago

  • Keywords has-patch added

#6 @DJPaul
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 @DJPaul
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 @imath
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 @imath
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

@vapvarun
3 years ago

Initial Patch

@vapvarun
3 years ago

update file name and fixed spelling mistake

@vapvarun
3 years ago

screenshot with bp-nouveau

@vapvarun
3 years ago

micro fixes in initial patch

@vapvarun
3 years ago

screenshot with bp-nouveau after leaving conversation

@vapvarun
3 years ago

legacy quit conversation

#13 @imath
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!

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


3 years ago

@vapvarun
3 years ago

updated with missing new file

#15 @imath
3 years ago

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

In 13196:

BP Messages: introduce a functionality to exit a messages thread

Exiting a messages thread is removing the user from the list of the recipients of the thread. The thread can carry on between the other recipients.

Props Oelita, vapvarun

Fixes #7540

Note: See TracTickets for help on using tickets.