Home › Forums › BP Better Messages › many threads with one user
- This topic has 14 replies, 3 voices, and was last updated 6 years, 8 months ago by Support.
-
AuthorPosts
-
March 21, 2018 at 10:19 am #6126AlfredParticipant
Hi,
I am using web socket version of your plugin. I find out that I can create many threads with the same user. Is it possible to limit to have only one thread with specific user just like on messenger?
Cheers,
AlfredMarch 21, 2018 at 10:55 am #6127SupportKeymasterHi there!
Yes it’s possible by adding some filters and hooks.
Or just wait and I will add this option in next version 🙂
Thanks!
March 21, 2018 at 11:02 am #6128AlfredParticipantAndrij,
Thank you for such a quick answer. Can you provide me with those filters and hooks?
It is quite urgent 😉
Cheers,
AlfredMarch 21, 2018 at 11:05 am #6129SupportKeymasterI haven’t the code ready at the moment. I will send when I have!
March 21, 2018 at 11:07 am #6130AlfredParticipantThat’s great. I really appreciate it! When would it be ready?
March 21, 2018 at 11:58 am #6131SupportKeymasteradd_action( 'bp_better_messages_before_new_thread', 'disable_start_thread_if_thread_exist', 10, 2 ); function disable_start_thread_if_thread_exist(&$args, &$errors){ global $wpdb; $recipients = $args['recipients']; $threadExists = array(); foreach($recipients as $recipient){ $user = get_user_by('login', $recipient); $from = get_current_user_id(); $to = $user->ID; $query = $wpdb->prepare("SELECT {$wpdb->base_prefix}bp_messages_recipients.thread_id FROM {$wpdb->base_prefix}bp_messages_recipients INNER JOIN {$wpdb->base_prefix}bp_messages_recipients {$wpdb->base_prefix}bp_messages_recipients_1 ON {$wpdb->base_prefix}bp_messages_recipients.thread_id = {$wpdb->base_prefix}bp_messages_recipients_1.thread_id WHERE {$wpdb->base_prefix}bp_messages_recipients.user_id = %d AND {$wpdb->base_prefix}bp_messages_recipients.is_deleted = 0 AND {$wpdb->base_prefix}bp_messages_recipients_1.user_id = %d", $from, $to); $threads = $wpdb->get_col($query); if( count($threads) > 0) { $threadExists[] = $recipient; } } if(count($threadExists) > 0){ $message = sprintf(__('You already have threads with %s', 'bp-better-messages'), implode(', ', $threadExists)); $errors[] = $message; } }
March 22, 2018 at 10:57 am #6136AlfredParticipantAndrij,
That worked perfectly. Thanks!
Is it possible to open this particular existing thread automatically?Cheers,
AlfredMarch 22, 2018 at 2:35 pm #6137SupportKeymasterDid you tried fast threads?
March 24, 2018 at 10:36 am #6140AlfredParticipantHi Andrij,
After few days of using your solution I figured out that it is still possible to have many threads with one user. It can be done by using “Private message” button from profile header. After hitting this button user is redirected to new thread without ‘You already have threads with %s’ message.
Can you help me with figuring out how to fix this?Cheers,
AlfredMarch 24, 2018 at 10:48 am #6141PetrParticipantWhat is fast threads, please? I’m also looking for solution how to automatically open existing thread.
March 25, 2018 at 2:20 pm #6142SupportKeymasterHi there peoples!
I will made better solution including all your notices and place it here.
Thanks!
March 26, 2018 at 4:28 pm #6145AlfredParticipantAndrij,
That is great. When you will post it?
Cheers,
AlfredMarch 26, 2018 at 10:25 pm #6146SupportKeymasterI was need to change some code in core to make this functionality.
It will be included as option in plugin configuration in next update.
I just need to finish some other things before release.ETA is 3 to 5 days I think
- This reply was modified 6 years, 8 months ago by Support.
April 3, 2018 at 10:15 am #6149AlfredParticipantHi Andrij,
Any update?
Cheers,
AlfredApril 4, 2018 at 2:59 pm #6151 -
AuthorPosts
- You must be logged in to reply to this topic.