Home › Forums › Front End PM PRO › Hook to use before messages load › Reply To: Hook to use before messages load
February 21, 2018 at 7:28 pm
#11406
Alex Brearley
Participant
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;