Support Forum
Support › MB Frontend Submission › Unable to load MB Frontend Submission via Ajax - Permissions not allowed
I am trying to load the frontend submission shortcode within the PHP of an ajax request, using echo do shortcode().
The issue appears to be permissions related to the fact it's an ajax request.
For testing, this is a custom post type, User Role Manager has every permission granted, the test user is logged in and the author of the post. But still, when called via an ajax request, the MB shortcode returns "You are not allowed to edit this post".
Is there anything I can do here?
Some background to why I need this.
In another post I had asked how I could change the ID of the generated HTML code from a Frontend Submission shortcode, so I could have multiple on the same page. Because I have multiple posts be able to edit via frontend. I was told this is not a good idea.
So I thought a solution would be to call the form via ajax.
I don't see the need for the restrictive permissions here. Perhaps the solution is to hack MB plugin itself to remove them?
Thanks.
Hi,
It is not possible to display the frontend submission via Ajax request. Please refer to this topic https://support.metabox.io/topic/js-call-mb_frontend_form-shortcode/
A user also wants to do that but there is no way to load JS, CSS files when you call Ajax and render the frontend form by the function do_shortcode()
.
Ok, thanks.
Is there a way I can change the ID of generated HTML, so I can have multiple frontend submissions on the page at the same time?
I am trying to find a way to edit custom posts, without leaving the page (this could be pre-loaded or via ajax). I have multiple posts listed on the page, each with it's own edit button, and on clicking that button I would like to edit one or more custom meta box fields. Refreshing the page after edit is not a problem, I just don't want the user to have to leave the page with lists of posts while editing.
Hi,
The form will have the same fields and IDs on one page so it is not possible to accomplish this case with Meta Box. I will inform the development team to consider supporting this case in future updates.
Hi again,
One more question on this. If each field was put in it's own custom field group, and put on the frontend as a separate edit (so each field / column has an edit button), could multiple MB Frontend Submissions be on the page when they have different meta box IDs?
I can't edit / delete previous question. That solution wouldn't work. The problem would still be there, that with a list of posts, the same Frontend Submission forms would be with the same ID.
There is an easy solution here, though would mean modifying Meta Box plugin directly. If the Frontend Submission form used data-id and not id as the value for the field id, and then form id could be unique (ids should not be used as data anyway).
So I doubt that would require a huge change. Any insight how I could modify the plugin to do that?