I’ve been struggling with the same problem…when args[0] is publish, args[2] is not populated. You have to get it from the url.
if(substr($args[0],0,7)=="publish"){
$postid=$_GET["post"];
if(!isset($postid))return $allcaps;
}
else $postid=$args[2];
Related Posts:
- How to filter users on admin users page by custom meta field?
- is it possible to add “extra” table nav to edit-tags.php screens?
- What hook do I use to edit the post statuses option in admin?
- post_mime_types Filter not Working in List Mode
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- WordPress Rest filter for custom taxonomy gets applied to the admin area
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- Why my admin doesn’t work after adding rest_prepare_post filter?
- Add Sortable Column For All Post Types
- How to add ‘total’ value to custom column title on the posts list page
- views_edit-post filter not working (custom post type)
- Filter out comments with certain meta key/s in the admin backend
- Filter pre_get_posts does not modify Mine/All/Pending
- Prevent add_filter being applied to wp-admin pages
- How to add attributes to WordPress Admin Sub Menu List Items
- Media upload default title from file name
- Admin post list – adding an option to the date filter dropdown
- How to replace username with email address in users table
- Hide Posts In Back-end/Admin Based On User’s (Pseudo) Privileges Controlled by ACF
- Filter Pages by Custom Field (ACF) in admin area
- Echo string in admin panel footer beside version no
- Filter / add_action to upgrade.php page
- How to filter with dropdown in backend for custom data
- Having wp-admin on different domain
- WordPress: Issue with filtering users using date range
- How do I disable the warning “The backup of this post in your browser is different from the version below”?
- Sanitize and data validation with apply_filters() function
- How many filter/action hooks are healthy?
- Filter specific shortcode output?
- Insert new element to array with add_filter
- How to hook into unregistering a widget instance?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- How do I use the ‘http_request_host_is_external’ filter
- get_option() filtering and getting out of recursion
- Get excerpt from $post->post_content
- How can I filter Microsoft Word gunk from pasted content?
- How to disable all WordPress emails modularly and programatically?
- How do I know if author field was changed on post save?
- Allow Profile HTML for select users
- Remove date and category filters when editing custom post types
- WordPress 3.5+ upload tool filter
- Search with filters and title
- Use content custom filter for all shortcodes
- Filter all html output
- How to add data- attribute to tag
- How to trigger the core WPLANG to make automatically set a language when the theme is activated? [duplicate]
- Making a class available via actions filters
- Remove tags from the kses filter
- Overwrite default WordPress wording
- How to add a class to Tag cloud widget link?
- How to get all the predefined do_action() calls from an active theme
- WooCommerce Variable Product Price – Where is “From” text generated from?
- Using ‘posts_where’ on a query with a custom field
- How to add numeric slug for child page in WordPress 5.9?
- add_filter does not work as expected
- Custom Login Errors and variables I can use
- ‘the_content’ filter removing html tags from post content
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- Filter to shorten column content on edit-tags.php
- Proper after_setup_theme and wp_head cleanup
- Why doesn’t remove_action work in my plugin?
- Using a filter to modify Genesis wp_nav_menu
- Filters on Login Page
- the_excerpt filter doesn’t work as expected
- What is the earliest hook to modify post content?
- How to modify only part of a function through the filter
- Something is filtering my shortcodes… Can’t figure out what
- How can I apply filters in my class that extends Walker_Nav_Menu?
- How should I be using filters and is_single together?
- Remove actions/filters that are set with create_function()
- Remove get_template_part() from custom theme
- Hook in a sidebar widget and add some markup
- return get_the_tag_list with whitespace removed
- ‘manage_users_custom_column’ is a filter, but ‘manage_posts_custom_column’ is an action. Why?
- comment_notification_text filter not working
- Line Breaks are stripped off when direction property is found
- Modify author url display in edit-comments.php
- WordPress remove_filter not working
- Filter Post Title without affecting screen-reader-text
- Hook to change the site URL
- Strange behaviour of REGEX in a WordPress filter (trying to suppress emtpy paragraphs)
- Modify Contextual Help
- Widget image reorganize layout
- WordPress set featured image to first image of the post
- Modify category listing API response
- Auto-generated excerpt with shortcode and read more button/text link
- Add filter button to custom post type in admin area
- Converting restricted html in comments to bbcode
- What is the proper/best way to have multiple add_filter for wp-job-manager-resume
- Modify WooCommerce email shipping text value
- How to replace all images in all posts and pages with a different size?
- Using Filters To Change Page Title
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- using posts_where for meta data on pre_get_posts
- can’t output gray scaled image I’ve created using add_image_size
- How properly write function to filter content in a template for plugin “multiple content blocks”
- ACF Load Field Groups Programmatically [closed]
- Can you call a filter hook by “add_action”?
- Why isn’t this add_filter function working as expected?
- Adding filter to the Contact Form 7 response