By adding the function to the publish_post hook it executes when the post gets published as the page is refreshing. That’s whats causing the headers already sent message.
This looks like some sort of chat that gets saved back to the database. If this needs to run on the front end of the site you could hook into wp_footer:
add_action('wp_footer', 'node_wp' );
In your node_wp function you can get the id using
global $post; $post_id = $post->ID;
Related Posts:
- Dynamically Override Fancy Title
- What function to hook for changes made in status and visibility of a post
- WordPress after content Hook & external template part
- get_current_screen() return null
- Adding option to Gallery shortcode
- Call to undefined function is_home() or any conditional tags
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Function not working on any file other than the main plugin file
- Template file structure , wordpress hook for altering the template
- get_term_by() returning null on plugin
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Which hook should be used to add an action containing a redirect?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- function deactivate_plugins does not exist
- Understanding WordPress functions’ naming conventions
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- WordPress scheduled task is called but not executed
- When is it appropriate to put functions on page template vs. functions.php?
- How to modify post content before writing to database?
- How can i list current author’s categories?
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Plugin development, hooks, generate content
- Is it possible to create an action hook using do_action() within add_action()?
- Problems with removing admin bar
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- Check if I am in the Admin Panel (wp-admin)?
- What is the Difference between directly call a function and call a function using add_action?
- Call to undefined function get_blog_option()
- Undefined function wp_set_password
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Woocommerce – Hide a Column in Cart Table
- Plugin Uninstall and Deactivate via Options Menu
- Placement of Code in Plugin for hooking `save_post`
- How can I add a CSS rule to edit.php?
- Should action callbacks start with a verb?
- add more custom post types and custom role to the code
- Why is my javascript not invoked in my hooks except wp_head?
- Namespaced action and filter tags
- What filter should I use to insert a button inside on Media>Add New
- is user logged in not working
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Trying to understand order and frequency of action hooks firing
- Where can i find wordpress auto update code flows?
- how to search users by ajax live search
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Remove unwanted elements for a wp_nav_menu
- How to add user details to different tables immediately after user registration
- WordPress custom taxonomy check box to dropdown
- Force HTTPS 301 redirect with hook
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Function/Class to list categories with checkboxes
- Plugin uninstall function is not working
- Why wp_die() doesn’t work with wp_redirect but exit() works
- Remove an action by extending class and replacing it
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Bind a function with its own argument to show something dynamically after every content
- Apply styles to blockquote element with the WYSIWYG editor
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Update variable value via add_filter
- How to find list of all functions bind to a particular hook from my plugin?
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Overwriting a plugin function
- Writing editor content to a file
- Restrict certain actions to plugin-specific admin menu pages only
- Adding tables to dashboard pages programmatically?
- Custom Settings Plugin Save foreach checkboxes
- How to enhance a self developed plugin by its own plugin architecture
- How to update global variables in plugin activation callback?
- function add custom fields to media gallery
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- Make visible page only in the trash
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Hook for validating and rejecting frontend image upload
- Nested Hooks with do_action for performance reasons – safe/necessary?
- WordPress plugin how to run function when button is clicked
- remove different admin menu for specific users
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- plugin modal/popup integration best practice
- WordPress permalink setting
- Dynamic banner for use on external sites
- How can i call from custom fields to the category editor?
- Get user logged in status from within a plugin. $current_user not defined
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Send Webhook when post-status is publish or trash
- Using “add_image_size” to register custom image sizes inside plugins not working
- wp_head is not fired from the hook I have used in my plugin
- Trigger a JavaScript function based on the data fetched from Woo commerce hook