• Hi there. We are using a custom LMS plugin for a project, and we have a custom post type which is updated with new posts when users add their data on the front-end. For some reason, your notification doesn’t fire for both ‘post-type added’ and ‘post-type published’ triggers. I found a PHP function in the LMS plugin that is responsible for adding user data as a post to this custom post type, can I somehow use existing ‘post-type added’ trigger inside this function? So, I don’t need to create a custom trigger.

    Meaning, if this function runs successfully, fire the trigger ‘post-type added’.

    • This topic was modified 1 year, 11 months ago by VisedFAQ.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Kuba Mikita

    (@kubitomakita)

    Hi, looks like the action from the plugin might be running too early before our plugin initializes.

    Can you identify if the function responsible of saving the post data in the LMS plugin does any do_action() call? If yes, we might be able to hook into it and using a simple “proxy” approach pass it to our plugin

    Thread Starter VisedFAQ

    (@visedfaq)

    I can’t find a do_action() call inside a function, but I think we can create one if needed?

    I can see that the post is created via the wp_insert_post function there.

    Plugin Author Kuba Mikita

    (@kubitomakita)

    If it’s a 3rd party plugin, you won’t be able to add it, as it will be overwritten by the update (unless you fork the plugin, which is not recommended). Or is the plugin your own, and you can edit its codebase?

    Thread Starter VisedFAQ

    (@visedfaq)

    Plugin isn’t updated often, and I’ll make a note to myself that when it’s updated, I need to add some code again, so don’t worry about it. It’s much more important to us to add this notification.

    Thread Starter VisedFAQ

    (@visedfaq)

    Any update?

    Thread Starter VisedFAQ

    (@visedfaq)

    @kubitomakita Hello, so how do we add it?

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Hey, thanks for your patience.

    What you’ll need to do is add an action after the plugin saves all the data, like:

    do_action( 'notification_proxy_fsn4f58', $post_id )

    Where $post_id is the saved post.
    Then you’d need to define the proxy action, like this:

    add_action( 'notification_proxy_fsn4f58', function( $post_id ) {
        add_action( 'init', function() use ( $post_id ) {
            // Post added action, that trigger is listening for.
            do_action( 'wp_insert_post', $post_id, get_post( $post_id ), false );
        }, 100 );
    }, 10, 1 );

    I hope this makes sense and will work in your case!

    • This reply was modified 1 year, 11 months ago by Kuba Mikita. Reason: formatting
    Thread Starter VisedFAQ

    (@visedfaq)

    @kubitomakita Hello mate. I did everything as you said, I’ve tried adding the last code segment to different files, functions.php or in the plugin file before all other actions and functions – it doesn’t work, unfortunately. No email notification or even error log.
    Also, I thought about the Hash value of the notification I’ve created:

    Is there a way to utilize it after the main function is finished, so we can fire the notification effectively this way?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Notification doesn’t work’ is closed to new replies.