You should use the transition_post_status
to filter the content after submitting the post.
Try the below code in the functions.php
in your theme:
add_action( 'transition_post_status', '_new_post', 10, 3 );
function _new_post( $new_status, $old_status, $post ) {
if ( 'publish' !== $new_status or 'publish' === $old_status ) {
return;
}
if ( 'post' !== $post->post_type ) {
return;
} // restrict the filter to a specific post type
$plain_content = strip_tags( $post->post_content );
$new_post = array(
'ID' => $post->ID,
'post_content' => $plain_content,
);
wp_update_post( $new_post );
}
Related Posts:
- Does the number of downloads displayed for a plug-in in the WordPress.org plug-in directory include automatic updates?
- How to get home page ID?
- How to get the active theme’s slug?
- WordPress plugin executing code twice
- How to Override a Pluggable Function
- admin-ajax returning 400 error when request is made with Fetch API
- Does WordPress contain “default” anti-SQL injection code that responds with a 404 error?
- Which method is best to enqueue scripts
- How do I retrieve a list of popular plugins using the WordPress.org Plugin API?
- Removing blank spaces from scripts to reducing page load time
- How to override a theme function (within a class) using a plugin
- Is there a WordPress Plugin that allows voting “does this coupon work” on specific links like Retailmenot
- ACF for audio url in wordpress audio shortcode
- Don’t send notification if author comments his own post plugin help?
- Custom interval is not working
- Built in admin ajax hooks?
- dequeue not work
- ‘Easy Table’ Plugin has float issues
- Force plugin to fail activation
- Can anyone identify this like plugin (not facebook like)?
- Could someone please help me to add category id with in this query so this will return posts from a certain category?
- Adding a section to admin menu for global settings
- what the hook for displaying course list page for learndash plugin? [closed]
- Copyright messages for a particular set of pages
- Feature Differences between WordPress.com and Hosting on your Own Server?
- How do you add custom logo to entire themes
- wp_get_environment_type is undefined
- Is the wordpress user-model changed in wpmu?
- Dynamic CSS Vs Inline Issues in Code any Way around in a WordPress Themes?
- plugin development: problem with functions
- How to determine if a plugin affects your file-system
- How do plugins get executed automatically from wp-content?
- Force CSS and JS loading of plugin only where needed
- Solutions to repost categories into multisite blogs?
- how to find and correct plugin query performance issues
- Custom random quote widget breaks when used in multiple sidebars
- Building plugin with changeable custom post type values…advice needed
- Hooking in to replace the Sidebar/Widget areas
- Problem with $wpdb
- $wpdb->get_row returns column name instead of column value
- Is it wise to add plugins to the Object Cache?
- Why namespaces are rarely used in WordPress plugins?
- Remove ‘Check Compatibility’ from Plugins menu
- Uninstalling plugins across all sites
- WordPress “Categories to tags converter” not working. Pointing to import.php instead
- the_tags : can we insert a class
- Elementor: How to override global theme style settings? [closed]
- Add user role to generated plugin
- Modify page title and subtitle with a plugin
- override filter in a plugin
- Hook into the rendering of a WordPress Template
- Setting Email locale before retrieving gettext translations
- Is there a maximum length to a WordPress Page?
- I changed .live() to .on() but change is not reflected on the server
- Save user total active time after login in wordpress [closed]
- How to track analytics with a WordPress site under the same domain as my main site?
- How do I add an options page at the bottom of the list?
- What goes into wp_postmeta and why?
- Woocommerce product info in a sidebar?
- output the debug lines to the end of the page
- A question of etiquette when forking a plugin? [closed]
- how to request a script more than once in wordpress
- WordPress Plugin for pastimes/participation in contest [closed]
- Plugin to create unlimited custom shortcodes?
- How do I create pages within a WordPress post?
- Gutenberg default attributes are empty when accessing in edit
- Ajax 400 error when used inside a plugin
- How to add custom plugin data to the cart in woocommerce using custom button on product page?
- How can I display selected content from a seperate database in an Activity style widget?
- how to show all posts of each category in pages
- Error thrown Call to a member function get() on null
- Allowed memory size of 134217728 … wp-includes/wp-db.php on line 1989
- Pricing Calculator – WordPress
- reminder wp_schedule_event
- Undefined offset: 0 in WordPress after latest version upgrade [closed]
- Make the product page as homepage WooCommerce
- Adding shortcodes to multiple pages with function
- Genesis Child Theme – Customize body
- Media Dialog CSS broken in WP v.5.3.2
- Multiple wordpress installations with same plugin folder (Apache Virtualhost)
- Slide through page effect?
- Get a list of Product Categories inside a loop
- How to update plugins in a distributed wordpress scenario?
- What’s the preferred method of writing AJAX-enabled plugins?
- WordPress API hook
- jquery conflict with widget page
- Automatically add child pages to menu
- Infinite Scroll plugin scrolling truly “infinitely” (i.e. does not recognize end of posts)
- Simple Data Table Update and Page Integration
- How to add a box for list items?
- wp_update_post call really slow when official Facebook plugin is installed
- Simply Exclude – Category feed exclusion is excluding from category feed instead of just the main feed
- Woocommerce custom fields
- This plugin throws error on the events page only [closed]
- White Screen When Includding A Folder With PHP Files
- making a simple plugin
- Custom single-product page for product from category x
- How to Allow Users to Select Recipients In a WordPress Comment section?
- How to write a plugin that “listens” every time, an edit occurs?
- Product customizing quiz – quiz adding products to the cart