• Resolved jamesbe

    (@jamesbe)


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Use one of the *_post hooks.

    Example:

    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.

    Thread Starter jamesbe

    (@jamesbe)

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Writing a plug-in — help please’ is closed to new replies.