Can't create pages from front end ("add" button not working)
complete
C
Cat
When tapping "add drama," "add movie" or "add person" button at the bottom of the page after filling out the details, it doesn't submit.
Steps taken
- Filled out front-end details for adding drama/movie or person etc.
- Tapped "Add..." button at the bottom
- Page seems to load (pinwheel) but then stops and nothing happens.
Amrayu78
complete
Amrayu78
Max Romanchenko: Can you help look at this issue? Thank you.
Max Romanchenko
Amrayu78: I have identified the problem. The reason is custom code that prevents a duplicate from being saved in the data database. If I disable this section of code, the add form works as expected.
A Google search brought me to your request for toolset support (2019), lol
I changed this code because it was causing a critical error. The problem is now resolved. Check, please.
Amrayu78
Max Romanchenko: Thanks Max!
LOL, I'm fine with this code being disabled. Thanks!
I can confirm it's working now. Any clue why this code would cause issues now?
Max Romanchenko
Amrayu78: No, I haven't disabled this code completely because I think you still need this functionality (checking for duplicates by title). Please confirm this.
The code was causing an error because it was querying all post types on the form at the same time:
$args = array( "post_type" => array('drama', 'movie', 'special', 'person', 'fansubber'), "posts_per_page" => -1, "post_status" => array('publish ', 'pending') );
In simple words, when a user added a drama, a query was made for all posts types .
I don't think you need to query all of these post types on your add drama form.
Instead, I made a post type query based on the form:
if ($form_data['id'] == 33531) {
$args['post_type'] = array('drama');
} elseif ($form_data['id'] == 33555) {
$args['post_type'] = array('movie');
} elseif ($form_data['id'] == 33535) {
$args['post_type'] = array('special');
} elseif ($form_data['id'] == 33560) {
$args['post_type'] = array('person');
} elseif ($form_data['id'] == 33564) {
$args['post_type'] = array('fansubber');
}
That is, in the form for adding drama, the check for duplicates will be
only among dramas, in the form of adding a movie, the check for duplicates will only be among movies and so on.
Thus, the request to the database was reduced and the critical error went away and the form was submitted normally. I don't know why this error didn't occur on the old server...
P.S. I didn’t find this post type (fansubber) or the form for adding it:
$args['post_type'] = array('fansubber');
Perhaps this can be removed?
Amrayu78
Max Romanchenko: Hi Max,
Thanks for explaining. I can see why the form takes so long to save now. Yes, let's delete the part of the code that includes fansubber.
Thank you!
Max Romanchenko
Amrayu78: Done. Always happy to help.