[resolved] Writing a plug-in -- help please (3 posts)

  1. jamesbe
    Posted 5 years ago #

    Hi all,

    I hope someone can help me out here to at least point me in the proper direction so I can start writing a plug-in for wordpress. I am familiar with PHP and have "hacked" my copy of WP previously but hate doing so as upgrade really becomes a nightmare / impossible.

    What I want to do seems fairly simple from the surface. When a new article is published I want to run a function that performs a few tasks on my website / database. It is a separate database so I assume I'll just have to write a php script to do what I need to be done, but I can't seem to find the "trigger" of publishing an article.

    I would have to pass the article ID from wordpress to my new script and that is about it, any help? Thanks!

  2. s_ha_dum
    Posted 5 years ago #

    Use one of the *_post hooks.


    function myfunction($postID) {
       // do stuff
    add_action('publish_post', 'myfunction'); // if not in a class
    // add_action('publish_post', array(&$this, 'add_myfunction')); // if inside a class

    This should probably work from either a plugin or your theme's functions.php.

  3. jamesbe
    Posted 5 years ago #

    Thanks that is extremely helpful! And even easier than I thought it would be!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.