wp_die();
will run AFTER the post is published. You are checking whether the post is published or not, which means the post is already published, what’s done is done. You can update to post status from published to draft instead of using wp_die();
. The following code will do it:
function check_post_limit( $ID, $post ) {
$post = array( 'ID' => $ID, 'post_status' => 'draft' );
wp_update_post($post);
}
add_action( 'publish_post', 'check_post_limit', 10, 2 );
Related Posts:
- settings API: how to create a multi checkbox with blog categories?
- call_user_func_array expects parameter 1 to be a valid callback
- Code works, but warning about call_user_func_array() appears
- custom-background callback breaks media uploader
- Category callback box problem
- How to pass arguments from add_settings_field() to the callback function?
- current_shortcode() – detect currently used shortcode
- wp enqueue script using scripts from cdn with a safety callback
- Can an action callback prevent the parent from continuing execution?
- Image upload callback in new 3.5 media
- WordPress REST API – Permission Callbacks
- Using a private method as an action callback from within a class
- How to check if which hook triggered the call to a function?
- Callback for wp.autosave.server.triggerSave();
- How do I hook an Ajax request into a PHP callback?
- WP showing “warning: call_user_func_array()”, What to do?
- gutenberg dynamic block is returning 404
- Hooking a callback into the code within a Gutenberg block
- Add_settings_field() parameterizing callback?
- How to pass variable via $callback_args for add_meta_box
- ob_get_clean returns empty string, ob_get_flush outputs string
- replace current_page_item class in menu
- How do I use the control callback when creating a simple dashboard plugin
- How to get control choices from $setting object passed to sanitize_callback
- Is it possible to create an action hook using do_action() within add_action()?
- Extend Woocommerce rest api routes fails
- Get returned variable from a function to add_shortcode function
- PHP Warning: call_user_func() expects parameter 1 to be a valid callback
- esc_url not working within add_settings_field callback
- How to Override default update_count_callback for category
- Reference external file as a function
- Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?
- wp_insert_post() Callback?
- How to use wp_send_json_error?
- How can one utilize a variable as a callback function name for add_settings_field
- Callback URL in WordPress
- How to validate register settings array
- How do I check if AJAX nonces are implemented correctly?
- call_user_func_array() errors after migrating site with InstantWP
- How to define a callback for an URI?
- Gutenberg: How to check if a block is used in a paginated post?
- How to insert a record by clicking on the link using AJAX
- Problems with comments callback (Argument #1 is not an array?)
- Multiple options pages validation for a plugin
- WordPress Custom Menus Issue
- Using shortcode content with nested shortcode
- Callback to custom field is not working in WordPress REST API
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Shortcode function executed twice?
- Best practice for query_posts in responsive design?
- How to access $post from a callback function
- How to Dynamically Load Content Into Body of Bootstrap Modal Window?
- Customizer: Category Select Sanitize
- Settings API callback function inserts html quotes from nowhere
- Shortcode callback for add_action(‘wp_footer’)
- Filter Hook callback error, is it due to using $this inside a filter or something else?
- Filter an array with a callback – for single & multidimensional arrays
- Run function after a post has finished saving – callback function perhaps?
- Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Wppr_Public’ does not have a method ‘amp_support’
- How to return multiple arguments from AJAX callback function
- url – ajax loaded but no JS
- admin_notices action doesn’t trigger within save_post action
- How To Override A WooCommerce AJAX Function
- Callback After WordPress Customizer Complete Loading
- Customiser sections not being displayed with `active_callback`
- Ajax insert or update data
- Where is this function’s callback getting its arguments from?
- Detect device change (desktop, tablet or mobile) in Customizer
- register_settings callback function erases data
- Warning: call_user_func() expects parameter 1 to be a valid callback, function
- Retrieve post in AJAX Callback
- Problem with Class, Filters and Callbacks
- Plugin default settings hook
- How do i specify a url to which to redirect the user after he logs out from facebook?
- Default Gravatar not showing for pings
- Using call_user_func() within add_settings_section() within a Class
- Does adding a callback like this to wp_head allows you to add additional content?
- Add parameters to 3rd party callback function
- How to customize ‘children comments’ in WordPress?
- How to ‘clone’ select metabox options with a callback function? [closed]
- JavaScript missing from shortcode content
- CallBack URL for payment gateway redirecting to homepage instead of executing callback function
- “Class Not Found” in HTML Form Target PHP File that contains the class
- Update block once an API request returns with a value
- Warning and fatal error
- How to create callback function which returns all posts with specific data?
- What is the proper way to call a function (from functions.php) on a link click?
- standard callback function for wp_list_comments
- Ajax callback and shortcode functionality
- Calling PHP function doesn’t work in index.php
- How can i call a custom method on submission of a custom plugin post type?
- Hook into admin_notices after sending mail
- call user func array error after moved the site to new server
- First argument is expected to be a valid callback for cp_admin_init and _canonical_charset
- Reference external file as a function
- Meta boxes not showing up
- Rewrite rule to redirect to a particular filename.php
- Using Javascript Callback from plugin in a theme
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- Callback API for getting response from fygaro payment gateway