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 to add user details to different tables immediately after user registration
- template_redirect or admin-ajax.php?
- WordPress custom taxonomy check box to dropdown
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Force HTTPS 301 redirect with hook
- I have 2 plugins using the same wp_login action hook and one is not working
- WordPress function get_the_terms() returns ‘Invalid taxonomy’ error
- Add a new confirmation page before saving
- Checking for existence of a page by title?
- how to get context information inside my funcion
- WordPress class, using add_action to call member function does not work
- use of do_action() without any functions attached
- How dynamic action login_form_{action} is working
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- What happens when two or more plugins use the same hook?
- 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()?
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- How to get all queries’s results after they have executed?
- Function/Class to list categories with checkboxes
- wp_get_theme Warning: Illegal offset type
- Plugin uninstall function is not working
- Bug: Post needs to be updated twice when adding action for save_post hook
- Why wp_die() doesn’t work with wp_redirect but exit() works
- flush rewrite rules after plugin update?
- When does save_post hook fire on post save/update
- Plugin does not add action
- Remove an action by extending class and replacing it
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Add child pages to submenu automatically
- Print Dashboard submenu name and filename
- Autogenerate a Table of Contents
- After plugin activation hook
- How to replace default comments with custom HTML?
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How can I create a custom plugin that allows anonymous users to signup without registering?
- hook filter after the_content on a specific page
- 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
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- Why enqueue styles on hook?
- What’s the hook for filtering every texts of site?
- WordPress multisite,use same cookies across all website?
- Apply styles to blockquote element with the WYSIWYG editor
- Hook add_attachment error
- Associate multiple email addresses with the same user account, so they can log in with either
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Run command “composer install” when activating wordpress plugin
- unregister_setting() vs delete_option() for plugin update
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Update variable value via add_filter
- Add a check box in Menu Settings
- Custom filter not working
- hook update_option/updated_option empty $old_value and $value
- How to output functions from plugin inside theme
- Configure WordPress to Generate Scheme-less Relative URLs
- Hide one specific woocoomerce product
- wp_schedule_event is registered but function isn’t running
- 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
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Ajax +wordpress onClick link redirect to new page and create html content
- How to replace settings in WordPress plugin from a theme
- Redirect returning users to a certain page?
- Restrict certain actions to plugin-specific admin menu pages only
- Remove Permalink Meta Box not working?
- Adding tables to dashboard pages programmatically?
- Setting post_id for single.php based on URL without a redirect
- using admin functions on frontend
- Javascript Function Called Too Early in PHP Script
- Modify code for functions.php with specific twitter user url and hashtags
- can’t access some WordPress function from my plugin
- WP 3-way voting system: On to something! Please help!
- Custom Settings Plugin Save foreach checkboxes
- Customise Grouped Product display in Woocommerce with custom column
- Creating posts with links from a txt file
- Change the behaviour of a button
- Set the payment processor callbacks to a plugin
- Action / Hook when a new plugin is added
- apply_filters() and call_user_func() to define and call a function outside a class
- Can someone explain what’s the use of parse request function in WordPress?
- Getting Post ID at “stylesheet” and “template” hooks
- How to enhance a self developed plugin by its own plugin architecture
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Add default value from selection
- How to update global variables in plugin activation callback?