Below I’ve included two hooks you could use. There may be better hooks depending on what you’re trying to accomplish exactly but this is what you’ve asked for. At the bottom I’ve listed some helpful resources:
Publish Post Hook
http://codex.wordpress.org/Plugin_API/Action_Reference/publish_post
function published_post( $ID, $post ) {
if( $post->post_type == 'post' ) {
...
}
if( $post->post_type == 'page' ) {
...
}
}
add_action( 'publish_post', 'published_post', 10, 2 );
Comment Post Hook
function maybe_published_comment( $ID, $approval_bool ) {
...
}
add_action( 'comment_post', maybe_published_comment, 10, 2 );
Resources
Related Posts:
- How can I edit post data before it is saved?
- Calling plugin function inside custom plugin for onclick event
- Create a post builder skin in a plugin
- Are there action hooks for comments?
- How to remove a class function from a plugin by using remove_action()?
- Advanced WordPress plugin activation detection
- Add action to custom Function
- The function called on the wp head hook becomes null
- Use action, filter, or hook to append HTML to WordPress plugin function
- add query string to all pages after user logged in
- How wordpress plugin hooks works? [duplicate]
- How to Add Extra Text In WordPress Title Before Post Publish
- Best collection of code for your 'functions.php' file [closed]
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- Remote upload file to server B
- Customizing subject in comment notification e-mails
- How can I log a user out of WordPress before the page loads?
- WP showing “warning: call_user_func_array()”, What to do?
- WordPress admin notice in plugin function
- How can I limit functionality in one version of a plugin?
- Seeking clarification on page request life-cycle
- Shortcode display outside the div
- Post source link plugin – small modification
- Use external link in the add sub menu
- How to remove action from plugin?
- Can a plugin add to header/footer/body content?
- Fatal error: Class not found in
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- How to find out what blocks are added by a plugin
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- template_redirect not being called when using ajax
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- How to add rewrite rules and pagination to retrieve attachments files?
- Plugin custom Action Hook not working
- What are the benefit in adding hook in the init() hook?
- Debugging Technique Question re: functions.php
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- Where to hook my plugin’s action
- Pass info from functions.php to plugin
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- WordPress filter that hook after each action/filter hook
- Insert new user with form submit ‘init’ hook
- Edit Yoast SEO breadcrumbs output [closed]
- How to get all of the activate_plugin action parameters?
- Using a post-signup hook to get user details
- get current date + 90 days and checking every day
- Calling an attribute from a plugin shortcode
- Modify custom field input data before creating a new post
- How to get post ID with hooks publish_post, new_to_publish, etc
- What is @Action in WordPress?
- a weird attribute on every html tag
- the_post hook is not firing for me
- Why do plugins often ask to add in to templates?
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Hook for page Request?
- WooCommerce: after install hook
- Overriding an Array in a Plugin’s Class/Function from functions.php
- Change Header (Logo) Based on Login
- Hook for altering the content of all wp mails
- Action on WordPress Install
- What hook can I use to modify custom post data before it is displayed on the page?
- Call javascript functions from each page
- Hook from plugin doesn’t fire up from external PHP script
- implement custom roles in custom plugin
- WordPress Custom Hook with Class method
- update_option_{$option} not working (do function after options are saved)
- Alternative Hook to the_content for Changing Background Color
- Unpublished Pages Failing To Appear On Custom Path
- add a hook of Woocommerce to a plugin but it only shows and doesn’t function properly
- Post source link plugin – small modification
- Callback hooked to post_updated firing on new posts as well
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- ACF Fields are not showing up on Homepage
- Adding discount functionality to the cart
- Precheck fields when I add a new post
- Hooking into the HTML header container
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- working code, not working – Plugin Dev
- How to Unhook actions/filters in within Class in plugin
- Plugin function in child theme
- WPML – Hook when language is switched (change user language)
- Passing function into add_action always returns the first argument
- {status}_{post_type} does not run correctly?
- Customize plugin templates
- Why is WP template_include overwritting all templates rather than specified page?
- plugin not hooking to my custom hook
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- wp_login_form() ignoring login_form action hook
- Passing a parameter to filter and action functions
- how to repeat taxonomy in different places on wordpress
- Plugin Hook: Get posts
- functions.php conditional output for a single plugin
- OOP Plugin: Where should I place the action hooks in the class?
- Call a function with href
- WordPress: code structure
- How to disable plugin capability : “create new category”
- Product customizing quiz – quiz adding products to the cart