You generally use add_filter
before displaying information. For your case you can use add_action('publish_post', 'your_function')
and then you intercept $_POST
values. The content of the WYSIWYG editor is available through $_POST['content']
.
The hook is of type publish_{post_type}
btw. You should change accordingly.
Example:
function wpse_89292_save_my_post()
{
print_r( $_POST['content'] ); # will display contents of the default wysiwyg editor
die;
}
add_action('publish_post', 'wpse_89292_save_my_post');
Using wp_insert_post_data
filter:
function wpse_89292_save_my_post( $content ) {
global $post;
if( isset($post) && get_post_type( $post->ID ) == 'post' ){
$content['post_content'] = function_to_manipulate_the_content();
}
return $content;
}
add_filter( 'wp_insert_post_data', 'wpse_89292_save_my_posts' );
Related Posts:
- Difference Between Filter and Action Hooks?
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How do I Make a Theme “plugin-ready”?
- Actions or filters fired when data is saved in a custom table
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- Hook for post permalink update
- Dynamically Override Fancy Title
- Define a function outside a class and call the function using action or filter hook
- Synchronize Custom post type tags to WordPress default posts tags
- Woocommerce – Hide a Column in Cart Table
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- WordPress after content Hook & external template part
- Namespaced action and filter tags
- best practice for query string values – get_query_var always empty for my value supplied in query string
- get_current_screen() return null
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- WordPress custom taxonomy check box to dropdown
- How to get all queries’s results after they have executed?
- Remove an action by extending class and replacing it
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Update variable value via add_filter
- Configure WordPress to Generate Scheme-less Relative URLs
- How to find list of all functions bind to a particular hook from my plugin?
- apply_filters() and call_user_func() to define and call a function outside a class
- Limit get_next_post to posts from the same author
- Any way, hook to add content right before the “read more” link?
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- Add_action not calling callback function
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- How to filter get_adjacent_post()?
- How do I replace title with my plugin?
- Apply function on all action hooks?
- How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
- Ninja Forms: Front-End Forms, Post ID?
- How can I replace content in the WP Admin area before an admin page is rendered?
- Plugin Development for registered users
- How to filter content for specific content variable
- template_redirect or admin-ajax.php?
- Force HTTPS 301 redirect with hook
- I have 2 plugins using the same wp_login action hook and one is not working
- Using ob_get_content to get_search_form puts into infinite loop
- Add a new confirmation page before saving
- Valid filenames for add_action’s first parameter
- How do I access the menus produced by Dashboard > Appearance > Menus
- Optimising a big WordPress site
- wpdb->prepare and mysql UPDATE – how is it done?
- dbDelta SQL Query Not Working
- 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
- dbDelta not installing database
- What happens when two or more plugins use the same hook?
- 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?
- Is it necessary to do validation again when retrieving data from database?
- How to get the post excerpt using post object?
- What is the best way to store a few fields?
- Plugin uninstall function is not working
- Plugin: database creation
- Adding columns to core tables
- Bug: Post needs to be updated twice when adding action for save_post hook
- How to query custom db table?
- Delete data from database using row action
- Show dynamic list of products from custom api of another database under same host
- flush rewrite rules after plugin update?
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- When does save_post hook fire on post save/update
- Plugin does not add action
- Add child pages to submenu automatically
- 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?
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- 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?
- Make Database query only when option is updated
- Can we intercept user_login and user_pass from a wp_login_form?
- How best to handle database version dependence (from $wp_db_version)
- Associate multiple email addresses with the same user account, so they can log in with either
- WP: Search and replace in DB programmatically
- Run command “composer install” when activating wordpress plugin
- Using AND and bracket grouping in SQL not working
- Add a check box in Menu Settings
- Custom filter not working
- hook update_option/updated_option empty $old_value and $value
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- Make wordpress join default user metas with a column from another table while displaying the wp_users table on the users screen
- Hide one specific woocoomerce product
- Gravity Forms Anchor only on Front Page?
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?