Hey @ulinn
Sorry I just took another look at your code and found the issue – in update_post_meta, you are setting the value of the _thumbnail_id meta to the variable $downloadcenter_id which has not been defined.
Update that line to the following –
update_post_meta($post_id, '_thumbnail_id', $attachment_id);
Test and let me know if you still have any issues with it!
Is the slug you’ve used inside has_category() correct?
Unfortunately I don’t think that is how the Private visibility works – that’s what I tried to do with my earlier reply. So don’t put your credentials on here!
Whoops sorry @ulinn
Can you check your Site Health on the WordPress dashboard and check that you have all the PHP extensions that WordPress needs? I’ve previously had an issue where WordPress could not create a thumbnail for a PDF because there was a missing extension.
Otherwise I’d be happy to take a quick look at the site if you want me to.
Hey mate,
Yes, the code is still working with 5.9.2.
A couple things that you need to make sure of –
Let me know if you still can’t get it working after checking the above.
Understood, thanks John.
Would allocating more resources help the server save the data quicker so the timeout doesn’t happen? I can increase the memory and CPU limit of the hosting server.
I think there’s an average of 13 rows being submitted. There’s 12 other fields (3 text, 1 Google Map, 2 groups with 3 and 2 text fields, 1 radio, 2 true/false). The redirect URL is the existing page’s URL with the post ID added to the end.
Understood re. AJAX and still needing to address the timeout.
I think it is a timeout, I can’t see any errors logged. How dangerous would it be to increase the max_execution_time on PHP to a minute? Strange thing is, even if the user gets a blank screen on submitting the form, all the form data is saved as a post as expected.
Would love to check out your plugin, where would I find it?
Thanks for always coming to the rescue John!
Gotcha, I didn’t think I was the first person to come across this issue! The form has a repeater with 5 fields for each row so that wouldn’t help one bit.
All the form data is being saved even if the user get a blank screen so that’s good.
Would an AJAX submission of the form save the user from seeing the blank screen? Would the browser wait longer than 30 seconds to get a response from an AJAX request? At least then we can show the user a loading/progress bar saying something along the lines of “your entry is being saved, do not close this browser window” and then redirect once the save is complete?
Nice one!
Re: creating/deleting posts as needed – each of my repeater rows require a file upload so I might use that attachment ID as a ‘key’ for each row to then create/update/delete posts as needed!
Thanks for your response @hube2 , you’re always so helpful on here!
I definitely would have set them up as CPTs instead of repeater rows if I knew the client would want them to be searchable individually!
I might loop through all the repeater rows and create them as a posts on a hidden/private CPT so that they can still be searchable
@hube2 I came up with an alternate solution using a Search and Replace plugin (Better Search Replace by Delicious Brains who now owns ACF of course!)
I did a search and replace on the wp_usermeta table for the typo and replaced it with the correct spelling. I then went into the checkbox field setting and fixed the typo. After that I checked any users who had the typo selected and their choice had updated (and remained checked)!
Thanks for your response @hube2 !
In the acf/load_value filter, would I loop through all the users using a WP_User_Query? I’m not quite sure how I would check if the user has the old value selected to then replace with the new value.
Do I need to rely on each user clicking update on the front end form for the changes (selection of the new value) to come into effect?
This code is actually working – it’s some other code I have written that causes the 503 error!
Thanks John, I’ll give this a go and get back with results!
I thought using the repeater with image fields was the best solution for this – but what would happen to the images when a row is deleted?
I guess they would remain in the Media Gallery and then increase the disk usage on the server over time as people upload and change their images?
Would appreciate anyone’s advice on a good way to approach Gallery fields on a front end form for users that have a Subscriber level of access.
Hi guys,
I’m using this code to load checkboxes to select posts, but I’d like to show the post heirachy.
It is possible to add divs around the list items that ACF creates for checkboxes? Or add classes to the checkbox list items that this code creates?
Thanks in advance.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.