If you want to target only one specific status change is probably easy / efficient use the
{$old_status}_to_{$new_status}
filter, in your case:
add_action('draft-to-pending', 'do_something');
add_action('auto-draft-to-pending', 'do_something');
function do_something ( $post ) {
// do something with the $post object
}
Related Posts:
- Check if post is being published for the first time, or is an already published post being updated
- What add_action reference should I be using or should I use do_action?
- remove_action on after_setup_theme not working from child theme
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- Trying to use add_action and do_action with parameters
- WordPress Theme Update Action?
- Extract image from content and set it as the featured image
- add_action in a function, is it possible?
- Using a private method as an action callback from within a class
- Refresh page after form action
- How to restrict actions and filters “properly” by conditions
- Add action hook conditionally – only when home.php in use
- Using add_filter() in Widgets
- How can I tell if I’m on a login page? [duplicate]
- Change meta tags programatically
- Convert hyphen to underscore in permalinks
- How to hook into the quick edit action?
- change a post status when users update posts?
- Reuse variable in hook callback
- Call to undefined add_action() in theme’s functions.php
- WooCommerce add_action hook results in 500 error
- How do I call wp_mail from HTML?
- Trouble using antispambot()
- How would go about if I just want a temporary function?
- Pass parameters to function through an action
- Accepted arguments value in hook functions
- How to select a page within admin?
- How to manage arrays from custom functions stored in functions.php?
- How do I pass arguments for multiple functions hooked to a single action?
- Which action hook to use for function?
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- Don’t delete a page if it holds users
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Contact Form 7 – Delay auto responds
- wp-comment author- url +, email filter hook
- Is there an alternative to get_template_directory_uri()?
- Reuse variable in hook callback
- Wait a result before enqueue
- Multiple Loops Meta Data
- Function added using `add_action()` not being called
- jQuery does not work
- Override the WordPress core function wp_referer_field
- Deprecated function get_user_by_email($email)
- Two functions with different arguments and add_actions, but identical code
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- I can’t seem to install Font Awesome locally [closed]
- Scripts not loading when using the wp_enqueue_scripts action
- Is there a way to prevent a function/method from being called outside a specific hook?
- Auto-Tweet if Type is ‘Status’ using OAuth
- problem loading stylesheets to wp_head dynamically
- current_user_can comma list vs OR (||) list
- Adding code before post title with the_title produces weird results
- How to properly refresh page after form action?
- Init action and refresh page after form action
- 400 Bad Request – JavaScript App calling Custom wp-json endpoint
- Changing where my author box is printed
- Insert Content Before div#main from the functions.php File
- Use add_action within template
- Problem in using Customizer
- Problem with custom function when I go back with the browser
- Replace admin header logo with an image
- New checkbox in custom widget isn’t saving data
- How do I find the code executed when wp_head() is called?
- template_redirect action only firing if logged in
- How to use wp_enqueue_script properly?
- Using get_terms for custom taxonomy in functions.php
- Fetch ids of live posts only (not posts with other statuses) and change status with a button in candidate dashboard
- Issue passing action class to nested function. Admin Columns
- Does hook have an effect on increasing the page load?
- Paragraph spaces in email template function
- How to Override Page Template if URL matches query?
- Save_post – Warning: Cannot modify header information
- What is the earliest Hook a Script can use?
- How do I trigger WP CLI DB export using a PHP function?
- Modifying a WordPress Plugin
- post value to function with Ajax and jQuery
- How do you insert code into the sidebar?
- How Do I Unhook This Parent Theme Function?
- If click on Save/Publish change Post Status to Pending Review instead Publish
- use add_action in a shortcode (gravity form – WordPress)
- wp_footer hook causing text to show on bottom of page
- How to change form action of wp-login page with a function
- Problem with email function
- Which method is more correct for removing WooCommerce Extensions menu item?
- WordPress hooks to call a function inside a construct
- True parameter but jquery register in header and not in the footer with wp_register_script
- Fatal error: Call to undefined function add_action() – an untouched problem
- Sending Messages Back to the Template After Processing?
- Pass arguments to function class with do_action()
- previous_post_link inside of a function?
- custom COOKIE on custom page
- function to return comma separated list of meta values
- Welcome Mails based on user role
- add variable to actions/functions across different files (woocommerce)
- How to hook wp_mail to add a custom email as BCC for each sent email?
- Change Post status based on custom field date +1 day
- delete_term is not working properly with add_action()
- How to get variable from other function inside class function using add_action for Ajax call