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
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- 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
- How can I see all the actions attached to an “add_action” hook?
- Shared functionality in plugins and themes
- Remote upload file to server B
- How to only hook on Single.php after content?
- When can you get current page ID and initialize hooks right after?
- Customizing subject in comment notification e-mails
- How can I log a user out of WordPress before the page loads?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- WP showing “warning: call_user_func_array()”, What to do?
- Autogenerate wordpress shortcodes using array?
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- WooCommerce create new product and add to cart on form submit
- 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
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Use external link in the add sub menu
- Failed to invoke other hook from the init hook
- How to remove action from plugin?
- do_action and hook methods
- Can a plugin add to header/footer/body content?
- Fatal error: Class not found in
- Is it possible to add an action to the currently running action?
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- Is it possible to remove this action? (as it’s added just before it’s called)
- Over write plugin templates
- How to find out what blocks are added by a plugin
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- How to prevent action in ajax request, when in admin side?
- Modifying Footnote Plugin for Descriptive Title Attributes
- 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?
- Placement of Code in Plugin for hooking `save_post`
- Can I use a method from an existing plugin as an action hook?
- 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?
- Override the filter from plugin in child theme
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- 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
- How to stop or remove an action being called inside a function of an extended class
- Any hook for pre-plugin-update -either bulk or single plugin update
- wordpress plugin is not activating from widget
- 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
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Calling an attribute from a plugin shortcode
- Best place for short bio,image and button [closed]
- Modify custom field input data before creating a new post
- How to get post ID with hooks publish_post, new_to_publish, etc
- Redirect to another page using contact form 7? [closed]
- What is @Action in WordPress?
- edit_user_profile and show_user_profile are not firing inside a class
- 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?
- remove_action not removing add_action from constructor
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- 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?
- WordPress: code structure
- Hook automatic_updates_complete to autoupdate plugin
- How to disable plugin capability : “create new category”
- Product customizing quiz – quiz adding products to the cart
- WordPress Action Hook inside Classes
- Remove 3rd party plugin notices from within own plugin