That error is because you are not providing the post ID to check capabilities:
This line:
if( !current_user_can( 'edit_post' ) ) {
Should be:
if( !current_user_can( 'edit_post', $post_id ) ) {
Related Posts:
- Objective Best Practices for Plugin Development? [closed]
- How to get the path to the current theme?
- How can I add an option to the Page Template list from a Plugin?
- Inserting Taxonomy Terms During a Plugin Activation?
- wp_mail is undefined
- How do you use the plugin boilerplate loader class to hook actions and filters?
- Contact Form 7: wp_mail doesn’t work after update to 4.6
- Build path for a custom portfolio plugin
- How to save block attributes when the output doesn’t change
- Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
- Hourly WP schedule, do I need at least 1 visitor hourly?
- wp_query (and post_id) is empty in admin_init
- I should hide the API Key in a plugin?
- Some nav-menu filters do nothing
- Get returned variable from a function to add_shortcode function
- Why is my shortcode not working
- Creating option to allow user to select the page my plugin content will display on
- What is the difference between these two methods of writing $ instead of jQuery in WordPress [closed]
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Use php libarary in wordpress plugins
- Can’t get JS code to work with shortcode
- Tips for targeting widget dragable for WP Pointer on widgets.php page
- Plugin options page – form with two different submit buttons
- Show Parent category and Subcategory
- Scheduling a task using class methods
- Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script
- Add a panel to edit post
- Auto-Update Plugin Creating .tmp directory, not overwriting old version
- Cannot update …/tags folder in SVN Repository
- best practice for query string values – get_query_var always empty for my value supplied in query string
- update post meta for checkbox in the admin when inserted in the front-end
- Gutenberg Block showing invalid content on edit
- Register a sidebar in a WordPress plugin
- ORDER BY wp_post custom column name in wp_query
- How to implement filesystem cache in WordPress
- Check for template part, else filter content
- How can I add a custom “Text” widget to Appearance manager from functions.php?
- How to stop your plugin from executing on certain pages?
- Is it necessary to sanitize plugin options?
- what are the checksums surrounding keywords in the SQL generated by WP_Query and do I need to use them too?
- Search the product by tag or category not working
- Is it possible to make sure that only my plugins output is shown to the enduser?
- How to filter content for specific content variable
- PowerPress mobile media player
- You do not have sufficient permissions to access this page on a submenu
- Plugin generated virtual pages
- add javascript files only when plugin is called?
- wp_dropdown_roles() to replace option value = code
- WordPress function get_the_terms() returns ‘Invalid taxonomy’ error
- Trying to Implement .pdf File Upload in Admin for plugin
- Writing a wordpress plugin and trying to include the Facebook PHP SDK
- Codex Version Focus on Production or Nightly?
- Make a plugin page out of influence of the theme’s style
- plugin_dir_path wrong url
- 400 Bad Request, in wordpress theme development, wp_ajax
- Fatal error: Uncaught Error: Call to undefined function convert_to_screen()
- Return Value of load_plugin_textdomain
- Multiple array for post_content on plugin activation
- Using AND and bracket grouping in SQL not working
- Taxonomy archive page listing terms instead of posts
- How to call code when adding WooCommerce menu items via woocommerce_account_menu_items
- Check if the current user is author of first comment
- custom wp_editor does not save the content in plugin settings
- How do I force a download in the admin area?
- add_action wp_ajax_ not loading in plugin file WP Network
- How to avoid conflict of plugin style and theme style?
- Is it possible for two WordPress plugins to share the same code base?
- Login page too many redirects
- Configuring Xdebug with docker compose
- wp.media libary pdf type
- Add multiple checkboxes as single field to Custom Shipping Method Settings Page
- Jquery php request is returning a weird result
- register_meta not showing custom post type metabox data in rest api
- Load script on frontend from widget plugin
- Events Manager: Create custom Placeholder for use in Email notification
- Get the current post/page URL with plain permalinks
- Using the same class across multiple functions
- ajax multiple Values
- Change Label of custom post type
- Ajax Response Error | just getting error as the response
- admin-ajax.php returns “No Script Kiddies!” sometimes
- Ajax functionality not being called under wordpress plugin
- Widget won’t be activated
- Plugin outputs content of posts unbidden!
- Need to change buddypress profile url by add_rewrite_rule
- Add a description/hint field in the admin page of a plugin
- Generate activation url
- Client Profiles
- Saving multiple fields as array
- Serialized Data
- Undo operation not working in Rich text [Gutenberg]
- Update custom settings field in plugin
- URL rewrite parameter lost (add_rewrite_rule)
- PHPUnit Ajax Serialization of ‘Closure’ is not allowed
- Settings API not Saving to Database or Display
- Error using @wordpress/create-block to create multiple blocks on Windows
- How to get the value entered in the input field in wordpres
- Sanitize and Save metabox values
- How can I add a custom button to the post editor?
- How to use register_setting()