I can’t comment yet… so I will use an answer, I think you need to do it with ‘wp_insert_post_data’ filter.
You can see this in line 3523 here: https://developer.wordpress.org/reference/functions/wp_insert_post/
Your function need to have a parameter, which is an array. From there you should get the content from ‘post_content’ key.
add_filter( 'wp_insert_post_data', 'example' );
function example( $data ){
$post_content = $data['post_content'];
// ... do your stuff
$data['post_content'] = $post_content;
return $data
}
Note: this will not get the tinymce content, This will get the data right before it’s introduced in database. You should also take some attention at shortcodes, I don’t think that you can modify the content in shortcodes via that filter.
Hope it helps you, or someone else.
Related Posts:
- Detect a focus on wp_editor
- How to load WP_Editor JS files manually (with AJAX)?
- What do ++ and *+ mean?
- Matching a space in regex
- WordPress Visual Editor Stripping HTML Changes
- Add a class to links in the visual editor (how to get old dialog back)
- Correct regex for wp_embed_register_handler
- Shortcode to insert
- Hide old attachments from wp media library
- Add post class to the TinyMCE iframe?
- Add a wp editor to custom plugin and save data
- sql query to put quotes around numbers in img tag
- Dynamically add styles to WP TinyMCE editor
- Adding dropdowns to the tinyMCE editor
- Wrap First Character after in a tag
- wp_editor and WPAlchemy messes up tags when updating
- Removing unneccessary p-tags (Not every p)
- Bridging TinyMCE js and WordPress PHP?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- trigger html cleanup for all posts
- Extend PHP regex to cover “srcset” and “style” attributes
- Change tinyMCE editor to allow marked content when pasting from Word
- how to remove colon and white space in a string by php
- Get URL from shortcode tag
- get_users meta_query: REGEXP not working for matching new lines
- Preg_Match(): compilation failed unknown property name
- preg_replace regex problem
- How to add no follow to specific links?
- php preg_match with multiple patterns
- Extract links from content
- Wp_editor doesn’t send the required data
- How to make the WordPress Editor not accept HTML?
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Using wp_editor() when not logged stopped working
- Make wp_editor required
- Deny php execution in /wp-includes – using .htaccess in /wp-includes VS root folder
- WordPress add_rewrite_rule
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Add php function into .js file (for tinyMCE button)
- WordPress TinyMCE Add Button To The Full Screen Mode Editor
- Trouble using wordpress functions in a pop-up modal form
- Dynamically append custom post type to end of url
- Replace TinyMCE with Custom Built Editor
- How to strip/remove all blank spaces at the beginning/end of a search string
- Having trouble customizing toolbar on wp_editor
- How to cut a section of a URL from a string with a regular expression?
- How do I use WP_query with multiple post IDs?
- esc_attr() right way and use
- Where to include php files in wordpress and how to refer to them later [closed]
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to add a featured image to a existing post via php?
- How to add 2 posts under another post? Formatting should be intact
- wp_handle_upload_prefilter valid date from input file
- Browser title script ignoring is_page /else conditional [closed]
- How to get 2 or multiple custom post types in wordpress functions.php
- Interrupting $html.= ‘ for IF statement
- Asking popup for delete post in WordPress [closed]
- WP nonce invalid
- Create WP_Query to search for posts by their categories or their parent/child categories
- add_action shortcut?
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Function to capture a value and store it in a variable
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- Show a different code on front page to other pages
- Make PHP work with HTML tags
- Which is the correct way to conditionally enqueue a CSS file?
- Admin ToolBar not being displayed at top of site
- Why are the details of my todo not saving?
- Theme activation hook in php class
- How do I get an external php page to load using javascript
- Add title=”” to A PHP Code
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- Proper way to use WordPress function with AJAX PHP file
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- List of Events with Multiple Dates: Only NEXT Date
- Can/should we delete wordpress cron jobs with no action?
- Accessing an instanciated class
- Rewrite rule don’t work in wordpress on xamp
- Display Visual Composer shortcode if a post belongs in specific categories
- reset data of an array
- product_type_options get saved value [closed]
- How to create a widget with a populated dropdown?
- Get user by meta data key and velue
- Add another role to a user when they click a button?
- Custom theme admin-ajax.php 400 (Bad Request)
- Using wordpress functions in class and change my code to OOP PHP
- Unable to pass arguments to function used in add_action
- How to limit functionality of a woocommerce plugin to only certain user role?
- What is the proper way to call a function (from functions.php) on a link click?
- Use PHP code in Menu Admin Section
- Multiple sections in Theme Customizer overwritten
- Querying posts based off a jquery datepicker
- Odd page behaviour after removing sidebar
- Display a list of users with avatar filterable with alphabets
- Adding multiple emails to a
- Warning: Cannot modify header information
- Displaying categories
- Suddenly sessions and header location not working
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0