XF 2.0 Trying to update message based on xf_attachment data

AndyB

Well-known member
I'm creating an add-on called Audio plus. It's purpose is to show mp3 attachments in a player in the message.

Example of how the audio player is automatically inserted after a post with a mp3 attachment is saved.

pic001.webp

The problem is my add-on which is listening to the entity_post_save runs before the xf_attachment table is updated, so in order for the message to be updated, I have to edit/save the post after the initial saving of the post.

When my add-on runs on the initial post save, the xf_attachment table has the following:

1513043026855.webp

I'm listening to event entity_post_save.

PHP:
<?php

namespace Andy\AudioPlus;

use XF\Mvc\Entity\Entity;

class Listener
{
    public static function threadEntityPostSave(\XF\Mvc\Entity\Entity $entity)
    {
        // get postId
        $postId = $entity->post_id;
...
 
Last edited:
Top Bottom