The third parameter for transition_post_status
is the post object. Use it.
add_action( 'transition_post_status', 'dostuff', 10, 3 );
function dostuff( $new_status, $old_status, $post ) {
}
When in doubt, do not use globals. They are not reliable, they make your code hard to test and to read.
Related Posts:
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How can a plugin create a page/form in the front end?
- Looking for WordPress System Diagrams
- How to output message during plugin activation
- On the WordPress Admin section how do I link to submenu pages created for a plugin?
- How to provide translations for a WordPress TinyMCE plugin?
- Where do I start from
- Where is it better to start learning how to develop for WordPress?
- How do you create a custom edit.php / edit pages page
- Check the Version of an Enqueue’d External Library
- Is there any way to test if a function running only on plugin update is successfully running?
- Edit the output of wp_widget_rss_output()
- Change of query var in pre_get_posts not maintained
- Hook for post permalink update
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- How to Parse an Array of Elements in Gutenberg Block
- Load page template with custom content using a plugin
- How to put placeholder text in the main post input area?
- Overwrite default XMLRPC function from plugin
- WordPress Plugin Setting’s POST
- How to update total price of completed order in woocommerce? [closed]
- How do I create a custom api endpoint?
- Add tab to profile.php wordpress plugin development
- Sharing a common set of image files for media library, across all sites within multisite
- How do I add a custom sublevel menu specified in one directory to a custom top level menu specified in another directory?
- wp_localize_script and host/browser cache
- Plugin update not reflected in WordPress plugin page
- Get a custom table to an array
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Error : “Cannot use object of type WP_Post as array in”
- Replacing Scripts in Admin Load_Scripts
- How to filter content on Save/Publish to add rel=”nofollow” to all external links?
- How to show active version on wordpress.org of a published plugin?
- How should I store a log for my plugin
- How to create database table, add data, update and delete using wpdb via plugins?
- Find out Requires WP tag for a plugin when submitting it
- Extending theme PHP class in plugin
- Any ideas to trigger some code after plugin update?
- what is the difference between these phares?
- WP_Query filters
- Plugin Architecture Question: How to avoid using transients
- SSL certificate verify failed
- How to test plugin update through WordPress plugin updater without tagging new release in the repo
- How to load library scripts in admin from plugins in noConflict wrapper?
- wordpress how to query wp_options table
- rest_no_route on custom API endpoint wordpress
- WP and object persistence (or lack thereof)
- UWooCommerce – add cart discount programmatically?
- Additional classes `undefined` after saving post in Gutenberg
- How do you submit a Gutenberg plugin?
- Bad Request in AJAX
- Remove sidebar on single page using plugin API
- When does save_post hook fire on post save/update
- Multiple API Endpoints (wp_remote_get)
- plugin_dir_url & plugin_basename not working when plugin dir is outside wordpress dir
- How to replace default comments with custom HTML?
- Enqueuing scripts and styles in custom plugins
- Include file in plugin file
- WP nonce field checkbox prints checked=’checked’ outside input field
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- Creating two tables in database on activation hook
- Adding custom stylesheet into header.php using a plugin
- Developing the save function in Gutenberg blocks
- Detect change in site_url and home_url
- Adding Custom CSS with PHP
- How to remove/replace current page template?
- How to receive notification of deprecated API elements and functions?
- Using password protection to load different page elements?
- It is possible to pass $args that sent by add_settings_field() inside another function?
- Change reminder email date to 14 days before
- .htaccess with WordPress – create my own pretty url with parameters (above WordPress settings)
- Generating a password-protected front-end page via a plugin
- How do I add a 5 digit ZIP code validation to a Contact7 form?
- wp_remote_post not working with admin-post.php
- How can we stop showing short code in create or edit post section
- Adding Amchart Interface to WordPress API
- WordPress Own Rewrite Rules
- Default media uploader is not showing in wordpress website
- Delete Plugin Options with Verify
- Don’t print customizer styles when no setting has been used
- Load custom translation in custom plugin fails
- Buddy Press restrict the capability to edit users
- Plugin with functions inside a class & how to trigger WP CRON
- “Headers Already Sent” Nightmare on Plugin
- add_settings_error on validating plugin options API
- Uncaught ReferenceError: kpoejy is not defined
- Unable to show a message after plugin activation
- How to get an array out of a nav menu if it’s a plugin?
- Is there better way to do this without duplicating queries?
- How to create a simple plugin which show/hide an html code in wordpress?
- Can I access WordPress API’s from within plugin scripts?
- Is there a way to make is_search() always return false
- How to create custom frontend php page via plugin
- Translation of plugin Upload button
- Ajax url value to pass ‘variable’ to use in query
- Apply Filters Causing a 500 Internal Server Error
- Create wordpress dashboard metabox which spans all columns
- add_filter adds output in the head
- How can i add insertion point between inner blocks in my custom block like core blocks
- Update option hook not firing