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?
- Show all terms of a custom taxonomy?
- How to add some custom HTML to the edit posts page
- How can I get an XML export of my 1K+ posts WordPress instance?
- tag search using WP_Query
- Unable to post simple form data in HTML
- dynamic sidebar not showing anything
- javaScript in section of WP API
- PHP code to call image Caption, Alternative Text, and Decription?
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Can’t get wp_insert_post to work
- How to: PHP Log Out Link?
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- code is skipping a div
- Avoid parallax images hardcoding
- The response is not a valid JSON response, wordpress problems?
- How to use wp_add_inline_style for custom CSS added via shortcode?
- Form Security: nonce vs. jQuery
- meaning of (array)function()
- Accessing $post after PHP is executed
- Can a page contain php code?
- Last class on last headline?
- How to relocate paypal button gateway on checkout page in woocommerce
- Passing the name of selected color from the custom component to `render_callback`
- Admin submenu issue with PHP not detecting two strings as equal
- Adding data to custom wordpress database table
- How to add videos on my home page slider?
- select a single val though a table in wordpress
- How can I enter on the Thank you page in woocommerce the discount code I assigned to the product category?
- PHP inside echo HTML
- Filter ‘comment_notification_text’ not working
- How do I check if a product is in two categories?
- oceanwp+woo mobile cart sidebar text
- wordpress contact form messages not sending although it saying they were sent successfully with this php code
- Find out div class
- Using a PHP form, get the page title or any other element in the sent e-mail
- Custom field in PHP file
- How do I fix Undefined variable using $_POST in function?
- Check the database for a postmeta field
- How to display dual language menus and headers?
- Help hooking into user_register
- How to create a sub-page of sub-page?
- Featured Products not showing up in “Featured” area of homepage
- How to hide the Duplicate taxonomy values in WordPress?
- How can I include tags in wordpress search without a plugin
- Search bar for page that searches only particular page IDs
- Trying to display user meta by “name” – not by “ID”
- Redirect homepage /page/1/ to /blog/page/1/
- if conditional in sidebar plugin Password content shortcode
- Excerpt all post content Content Same Size without word cutting off
- understanding wp_next_scheduled
- How to add SKU and remove product title from WooCommerce url?
- php 8 compability admin interface
- How can I make below code to show grouping by country ranks in same div, example if in second loop rank 2nd must be show in same 2nd class div