Unread count by messages not thread
-
Hi.
Unread messages count by thread. Is it possible to count by individual messages?
I mean I have 5 unread messages in 2 different threads. It shows 2 in the notification. Because there are 2 threads. But in these 2 threads, there are 5 messages unread.
I checked mysql table and there I saw mgs_parent_read which shows 5, but mgs_read shows 2. (value as zero)
How to show total unread by mgs_parent_read?
Thanks in advance.
-
If you select Front End PM > Settings > General > Message view as “Individual” then it will show each message separately and also count separately.
If you want to show as threaded but count individually then you have to query messages to get those count. You can see class-fep-messages.php file user_message_count() method to get an idea how you can query.
Hi Shamim,
Thank you. Yes, this is what I want. Show as threaded but count individually.
I spent all night with your code but no luck ๐
I found and other method:
<?php global $wpdb; $current_user = wp_get_current_user(); $rows = $wpdb->get_results('SELECT * FROM wp_fep_participants WHERE mgs_participant="'.$user_id = $current_user->ID.'"'); $count = 0; foreach ($rows as $obj) : if( $obj->mgs_parent_read == 0) { $count++; } endforeach; if ($count == 0 ){ } else { echo $count; }
Loop mgs_parent_read values equal to zero and count them. It works but not efficient as your method. No ajax working with this method. ๐
Let me work on class-fep-messages.php.
Thank you for giving the idea. I will really appreciate if you could provide the exact line what I need to look at.
-
This reply was modified 6 years, 6 months ago by
Ahmet.
I found solution from different way.
I set show Message view as individual. Then counts all messages.
But to show message box as thread I copied all
if ( 'threaded' == fep_get_message_view() )
then make the same for
else
Now whether choose thread or individual, shows as thread. So choosing individual will show thread but will count as individual.
I dont want bothering you more, so this method works fine for me.
Sorry again.
Even if Message view set as individual, it does not show count when replied existing thread.
I mean it shows when there is also unread thread. But if there is no unread thread but unread message, it does not show.
Edit: Maybe my fault. I undo changes, back to normal. But now view style as individual.
Edit2: Okay need to not make all if else statement same. I did not touch the
_fep_user_message_count
part and did the same rest. And now it works as expected.Only need to figure out to add class “fep-strong” or “fep-unread-class” because in thread view not showing if unread message is a reply.
Finally I did.
I discovered when changing from thread to individual and vice versa, ask me to update the database.
So when set as individual and update database and set again to thread but not update database, it show thread view and count individual messages.
So I made some if else statement the same inside
class-fep-update.php
and just deletedif ( 'threaded' == fep_get_message_view() ) { $args['mgs_parent'] = 0; }
inside
class-fep-messages.php
Happy ๐
add following code in your themeโs (child themeโs if any) functions.php
add_filter( 'fep_message_count_query_args', function( $args, $user_id ) { unset( $args['mgs_parent'] ); return $args; }, 10, 2);
Thank you Shamim for providing the codes.
Unfortunately there is a serious issue with thread view.
When deleting threads, it deletes only the first message of thread and do not delete child messages.
When deleting all threads, there is no message left but it says Message box size:2 of 50.
So when changing to individual view, 2 message (RE:) show up.
https://pasteboard.co/HEbTVjh.png
Unfortunately I must use with individual view because people will delete some messages to gain space but with thread view there will be ghost messages.
-
This reply was modified 6 years, 6 months ago by
Ahmet.
I tried this but cannot reproduce.
keep in mind following
1. “Message View” setup was intended to use just one in the beginning. It should not be changed afterward.
2. When a user delete a message that does not delete that message from database if other user have access to that message. a message will only be deleted from database when all recipients of that message delete that same message.
3. As from your previous replies it seems you have changed code of this plugin. It is not possible to know for me what is changed and how that behaves with the functionality of the plugin.Shamim,
I installed the plugin on other domain. Did not edit any code.
With threaded view, if I delete a message, child messages still exist but cant see them. It does not need to delete from database, just need to ignore them if parent deleted.
I cannot reproduce this.
Did you still have this code https://wordpress.org/support/topic/unread-count-by-messages-not-thread/#post-10693204 ?Yes, I have it. Do you think because of that?
Yes.
This plugin is not designed to show individual message count when you are in threaded view. I just gave you that code to roughly correct count as you were editing plugin code.Remove that code then test.
Sure. I will.
Thank you for replying and solving issues.
Your plugin is really useful and functional. I will use it with individual view but let me test threaded view without this code.
-
This reply was modified 6 years, 6 months ago by
Ahmet.
Hi Shamim
Yes, removing that code solved the problem.
Thank you.
-
This reply was modified 6 years, 6 months ago by
Ahmet.
Shamim,
I finally found solution for this. I want to share with you. May be you can make 3rd view option for pro version.
I made 2 different $args for unread and total.
$args2 includes
['mgs_parent'] = 0;
but $args does not.$total_args = $args2;
$unread_args = $args;
See: https://cdn.pbrd.co/images/HECa9Aw.png
Thank you for this plugin.
-
This reply was modified 6 years, 6 months ago by
- The topic ‘Unread count by messages not thread’ is closed to new replies.