There’s a hook save_post, docs here: https://developer.wordpress.org/reference/hooks/save_post/ which will allow you to run some code after the post is saved. Example from there:
function add_user_after_post_save( $post_id ) {
// add a user?
// move the post to the user?
}
add_action( 'save_post', 'add_user_after_post_save' );
Not sure why you’d need to call the hook immediately before the post is created, as anything that you can do then you can also do in the save_post hook, but please provide more information.
Related Posts:
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Include WP_Query in my own PHP file?
- Using register_activation_hook in classes
- Is there a way for a plugin to add an attribute to the tag of a theme?
- How to use update and delete query in wordpress
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- add_meta_boxes action with refresh on save
- Resize Image without cropping
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- When is is_admin() available?
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Making Quote Plugin more efficient
- Hiding WordPress Plugin Source Code
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- Will simple function names in a class structure conflict with other plugins?
- Instantiate class to be available to all plugin functions
- How to test nonce with AJAX – Plugin development
- wp_loaded hook block script enquequing
- WP nonce invalid
- Custom filter in admin edit custom post type responding with invalid post type?
- How can i upload images in an admin page?
- How to find error in my code when the error message is pointing to WP core file?
- How to access global variable $menu inside a class function
- Custom user login page by creating a plugin
- Singelton class does not work, multiple initialization on page reload
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- How to upload a file to a folder named after the user_id via plugin
- Reprinting tags with all attributes
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- Update results, Before deleting the related category [closed]
- adjust section according to country?
- Adding function to Genesis genesis_header [closed]
- “Undefined index” error when saving empty array with checkboxes
- wp_insert_post: array only. wp_update_post: array|object (?)
- Is it save to use eval for a jQuery callback method coming from the database?
- Building a REST API for your web app exposes primary keys of DB records?
- Scheduling an event inside plugin class is not working
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Cant register rest routs from class instance
- wordpress frontend editor to add extra css to website
- Custom Registration username_exists / email_exists
- How can I search all plugins for composer’s vendor/autoload.php?
- PHP: How to access db the right way in plugin?
- select a single val though a table in wordpress
- WordPress – Get Posts with Category data
- Add a custom WooCommerce settings tab with sections
- How to use wp_send_json() and output the value with ajax?
- PHP using external anonymous function inside class
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Is it possible to access admin-ajax.php using PHP?
- Call to “admin_notices” hook from a static method
- How to Create custom block for displaying information in content section which act like shortcode
- How to detect and handle the time difference between server and user in WordPress?
- How to setup the Email piping in WordPress plugin?
- Reliable way to add nonce to HTTP Header in WordPress?
- Getting an error when my plugin is updated, but the files update correctly
- Creating a POP Alert
- Add Pre-Defined Value to Click Counter in WordPress
- ssl redirect function is not working
- Drop down question
- code that I can run, or a plug in to show what sql tables something pulls information from
- Automatic email message after manual user approval
- custom mailchimp form using HTTP API
- How to override theme’s public static function inside of a trait?
- pass datetime using wp_localize_script to frontend from settings page
- add custom metabox to media library custom widget
- using filter and hook inside class
- Display attached images of a page or post that are insetred using gallery
- overwrite wordpress gallery with custom gallery shortcode
- Enqueue sripts and styles only if function is called
- Add widget area from visual editor
- Register/enqueue scripts only on certain admin pages
- Looping through custom data in a custom table to display all items in a post
- Priority call methods – PHPMailer->addAddress(NULL)
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- WordPress Query Crashes Browser
- How to send logs to plugin owner for a plugin?
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Plugin Modification Change Functionality For Logged User Only
- Force CSV download with template_redirect
- INCOMING: Wall of code for form and $_POST, not updating custom field’s value
- add shortcode heading showing multiple time
- WP multisite network plugin fails to see classes loaded with spl autoload
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- What is this mark for “? function()” [closed]
- using a shortcode in a hyperlink
- How to automatically convert images to WebP on WordPress?
- Login user into magento using wordpress account
- Customize create table SQL statement in any WordPress plugin
- wp_register_script – illegal string offset
- Does it make sense to sanitize the output of an SVG file?
- check difference between two timestamp in custom plugin