I am encountering an issue with MB Frontend Submission when trying to allow users (including admins) to edit posts from a custom post type (artwork).
Details:
I have set up a page with the following URL: /edit-artwork/?post_id=208, which is intended to allow users to edit an artwork post with ID 208.
I am using the following shortcode on the page:
[mb_frontend_form id="your-form-id" post_id="{GET.post_id}" post_type="artwork" edit="true"]
Despite being logged in as an administrator (who has the capability to edit these posts from the WordPress admin dashboard), I receive the following message: "You are not allowed to edit this post".
Troubleshooting Steps:
I’ve ensured that the post ID and post type are correct in the URL and shortcode.
I’ve added the post_type="artwork" and edit="true" attributes to the shortcode.
I’ve added a filter to the theme’s functions.php to ensure that administrators and post authors can edit posts:
add_filter( 'rwmb_frontend_access', function( $can_edit, $post_id ) {
if ( current_user_can( 'administrator' ) || current_user_can( 'editor' ) ) {
return true;
}
if ( get_post_field( 'post_author', $post_id ) == get_current_user_id() ) {
return true;
}
return $can_edit;
}, 10, 2 );
Issue:
Despite these steps, I still receive the "You are not allowed to edit this post" message on the frontend form. Admins have no issues editing posts through the backend.
Steps to replicate the issue:
Go to https://yairm20.sg-host.com/ log in (in the login page - you will need to create an account) then go to the artist archive page that will appear in the menu. Inside it upload any photo from your computer and click submit. Now go to the Gallery test page and you should see the image that you uploaded and an edit button. If you will click on the edit button you will get You are not allowed to edit this post. in the new page instead of the edit form.
Could you please help me identify what might be causing this issue? Are there additional configuration steps or settings I might be missing in the post type setup or elsewhere?
Thank you for your assistance!