Home › Forums › Front End PM PRO › Hook to use before messages load
- This topic has 20 replies, 2 voices, and was last updated 6 years, 8 months ago by Shamim Hasan.
-
AuthorPosts
-
February 21, 2018 at 7:28 pm #11406Alex BrearleyParticipant
yes, you are right about $args :/ I’ve removed the child code for the time being. The child messages show if you chose the option to show each email rather than email thread. I have gone back to only showing email thread which resolves the issue.
I now have the following code but am still seeing the unread hidden messages being included in the count.
$this->loader->wp_add_filter('fep_message_query_args', array( $this->fep, 'cmdu_hide_message' ), 10, 2); $this->loader->wp_add_filter('fep_message_count_query_args', array( $this->fep, 'cmdu_hide_message' ), 10, 2);
public function cmdu_hide_message($args, $user_id) { // Admin users can see all if (! current_user_can('administrator')) { $args['post__not_in'] = $this->hide_mes_id(); } return $args; }
And inside private function hide_mes_id()
$not_post = array(); foreach ($findrefs as $ref) { array_push($not_post, $ref->mes_id); /* * $child_args = array( * 'post_parent' => $ref->mes_id, * 'post_type' => 'any', * 'numberposts' => - 1, * 'post_status' => 'any' * ); * $children = get_children($child_args); * * foreach ($children as $child) { * * array_push($not_post, $child); * } */ } return $not_post;
February 21, 2018 at 8:06 pm #11410Shamim HasanKeymasterPlease send a message to that user after added this code. That will delete previous cache for that user and show proper count.
It will be better if you can hide message when that message is sent rather then when view.
February 21, 2018 at 9:24 pm #11413Alex BrearleyParticipantHiding on send won’t work as the act of hiding is the result of some business logic that is asynchronous to the act of sending a message in the first instance. Would it be possible to mark messages as read when they are hidden or somehow force the cached message count to be refreshed once the messages are hidden?
February 21, 2018 at 9:29 pm #11415Shamim HasanKeymasterPlease send a message to that user after added this code. That should delete previous cache for that user and show proper count.
February 21, 2018 at 10:01 pm #11417Alex BrearleyParticipantI appreciate sending a message afterwards forces the cache to be reset but this does not meet the requirements – I would like messages to be hidden and then made visible based on a business logic status change and not when a message happens to be sent. Desired behaviour:
1. General message exchange, some messages read and some unread.
2. business process reaches a particular status and message are all hidden and the unread message count has unread hidden messages removed.
3. business process reaches another status and message are unhidden and the unread message count now includes the count of those previously hidden messages.Currently, If I move the business process to a state where they are supposed to be hidden, the messages are hidden and the unread count seems to be correct. However, when I move the process to the state where messages are visible again, they don’t get shown until I send another message to that user again.
February 22, 2018 at 11:22 am #11442Shamim HasanKeymasterWhen message in changed from hidden to shown add this code there, this will clear cache so that you get correct count.
$participants = fep_get_participants( $message_id ); foreach( $participants as $participant ) { delete_user_option( $participant, '_fep_user_message_count' ); }
change $message_id with which message is hidden to shown
-
AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.