Alex Brearley

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 34 total)
  • Author
    Posts
  • in reply to: Hook to use before messages load #11417
    Alex Brearley
    Participant

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

    in reply to: Hook to use before messages load #11413
    Alex Brearley
    Participant

    Hiding 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?

    in reply to: Hook to use before messages load #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;
    
    in reply to: Hook to use before messages load #11393
    Alex Brearley
    Participant

    No, I’m not overriding $args – as per your snippet above, I return $args at the end and my code is updating 1 element of the $args array as per your snippet. From testing, using your code example, just passing the parent message ID did not hide the children replies which is why I then added in the message ID’s of the children as well.

    Please can you expand on your statement about the cached message count. How do I use the hook to change it and maintain the count cache?

    in reply to: Show all replies on load #11344
    Alex Brearley
    Participant

    Excellent, thank you

    in reply to: Hook to use before messages load #11342
    Alex Brearley
    Participant

    I’ve also noticed that New message count and the New message banner that appears in the header is still showing even though the messages that are new are the ones I have hidden i.e. when I click on the messagebox I correctly get ‘No messages found. Try different filter.’ due to the messages being hidden, the MessageBox button still shows a count of messages unread (all hidden) and the banner in the header is also showing unread messages, again, all of which are hidden.

    Is there a hook to adjust the number of unread messages count to take into account the messages that have been hidden?

    in reply to: Hook to use before messages load #11340
    Alex Brearley
    Participant

    $not_post = array();
    foreach ($findrefs as $ref) {
    array_push($not_post, $ref->mes_id);

    $args = array(
    ‘post_parent’ => $ref->mes_id,
    ‘post_type’ => ‘any’,
    ‘numberposts’ => – 1,
    ‘post_status’ => ‘any’
    );
    $children = get_children($args);

    foreach ($children as $child) {

    array_push($not_post, $child);
    }
    }

    $args[‘post__not_in’] = $not_post;

    $findrefs is an object that contains a list of parent message id

    in reply to: Hook to use before messages load #11300
    Alex Brearley
    Participant

    Thanks – I also added

    $args = array(
    ‘post_parent’ => $ref->mes_id,
    ‘post_type’ => ‘any’,
    ‘numberposts’ => – 1,
    ‘post_status’ => ‘any’
    );
    $children = get_children($args);

    foreach ($children as $child) {

    array_push($not_post, $child);
    }

    As it worked for the parent message but all the children were still shown.

    in reply to: Making message read-only #11255
    Alex Brearley
    Participant

    I can see what the issue is, should be if ( (‘send_reply’ === $cap) and not if ( (‘send_reply’ !== $cap)

    I have also used wp_get_post_parent_id to get parent ID’s of reply messages to check those as well

    in reply to: Making message read-only #11237
    Alex Brearley
    Participant

    So I’ve tested this out and not quite what I wanted. If I attempt to view the first (parent) message, I get an error saying I do not have permission to view the message – what I wanted was to be able to view the message but not reply (read-only). Also, it has no affect on the children of the first message/post i.e. if I click on a reply message, I can view and reply again.

    in reply to: Hook to use before messages load #11235
    Alex Brearley
    Participant

    This isn’t quite what I’m looking for. What I want to do is prevent a particular message being displayed in the inbox based on parent message ID. I think this function is high level filter for posts to display. Do you have any other ideas how I could do this?

    in reply to: Hook to use before messages load #11169
    Alex Brearley
    Participant

    usual question, how many arguments and what are they?

    in reply to: Hook to use before messages load #11163
    Alex Brearley
    Participant

    Before messagebox is loaded so that I can hide messages before they are loaded

    in reply to: Making message read-only #11122
    Alex Brearley
    Participant

    Worked in child theme. Turned out to be a typo in my wp_add_filter function that meant the num of args was not being passed – doh!

    in reply to: Making message read-only #11110
    Alex Brearley
    Participant

    Should add this error occurs on every page load of the website – not when specifically using FEP

Viewing 15 posts - 1 through 15 (of 34 total)