WordPress.org

Forums

WP-PostViews
[resolved] Hook into PostView increment function to send email (5 posts)

  1. srumery
    Member
    Posted 1 year ago #

    Hello Lester,

    Out of the box, this plugin works great. Thank you.

    I have a specific case where I need to send an email when a page is viewed. I am using WP Super Cache with Nginx to serve up static files so I can't write a PHP function that works on the page, I need to use Ajax. Hooking into your plugin seems like a great solution.

    What would be the best way to do that? Can I hook into the wp_ajax_postviews action in a custom plugin and use another function to execute an email?

    https://wordpress.org/plugins/wp-postviews/

  2. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

    Hi srumery,

    Thanks! I added those action for you since they are valid and I agree with you. You can download the dev version to give it a try https://github.com/lesterchan/wp-postviews/archive/master.zip

    You just hook onto 'postviews_increment_views_ajax'

    Here is the changelog: https://github.com/lesterchan/wp-postviews/commit/d69d1a7d33cd30667d92443a1084f1f8ffdcae42

  3. srumery
    Member
    Posted 1 year ago #

    Brilliant! Thank you, Lester.

  4. srumery
    Member
    Posted 1 year ago #

    The new hooks work great. Now I can use WP-PostViews to trigger actions for custom WordPress applications. Thank you!

  5. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

    No problem =)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.