I'm trying to improve the workflow of my website, and I thought I'd found a code snippet that would work, but it doesn't seem to be. I wonder if anyone can help me understand what I'm getting wrong.
This is what I would like to happen:
The first 3 steps are working, and although I can edit the post and publish it what actually gets published is still what is in the form entry. If I update the form entry it updates the post. SO what seems to have happened is that the link between the form entry and the post is not severed, it has just become one-way, form->post.
Any ideas on what I should check?
Did you verify that the code line to update the entry was run and returned a non-zero value? You can do it either by putting debug commands in your snippet or by looking at the database and seeing if the post_id column was cleared out.
I'm not sure that I've got the debugging working correctly. It's showing some errors in the log (for other things, like translations loading at the wrong time), but nothing about what scripts are run when the entry is updated.
But it seems pretty clear that the script isn't working as after the entry in FF is updated, a field appears in the righthand sidebar of the edit entry page showing a link to the post. Presumably if the post was detached this would not be there.
You're not looking for errors; rather, you're looking for whether the code is called and, if so, what happens inside the code. You can use the error_log command to output that information to the log file.
Nice job on getting the details. I can't tell you if 5520 is the correct post id. I suggest you add the output of the entry ID to make sure it's what you think. Clearly, it has a post_id, so that's a good start. Then you'll have to look in the database at the post_meta table to see if there's an entry with both 5520 as its post_id and frm_display_id as its meta_key. It's kind of impossible for it to fail if that combination exists. In conclusion, verify that the entry ID and post ID are correct and that the aforementioned combination does exist.
Great, now your entry is gone from the post. This forum software is starting to drive me nuts.
Yes, sorry. It's me. It keeps messing up the formatting so I've deleted it a couple of time trying to sort it out. I just tried to upload the script, but that's not working either.
Thanks for all your help with this Rob - and for bearing with me while I get frustrated with this forum software!
Just make sure you see my comment in response to your missing comment. For code, I suggest always using a code pasting site such as pastebin and add a link to your paste rather than the code.
Right, I've got it to output the entry ID as well, like this:
error_log( "Failed to delete meta for post ID: {$entry->post_id} - Entry ID: {$entry_id}" );
And they are clearly different:
[29-Apr-2025 15:16:50 UTC] Failed to delete meta for post ID: 5521 - Entry ID: 2288
Different is good, but it doesn't really help. The questions are A) whether that entry id and post id are the same as what you're looking at in the UI and B) whether the entry post_id/'frm_display_id' meta key combination exists in the database. If it does, then the question is why it won't delete it. If it doesn't exist then it has to be that the entry id and post id are not what you think they are are. If it does exist, the only thing I can think of, and I don't even know if it's possible, that the user deleting doesn't have permission to do that. One thing I can say for sure is that when you figure it out, you'll say "ohhhhh".
It looks to me like the only entry in postmeta with post_id 5520 does not have frm_display_id as its meta_key
https://1drv.ms/i/c/09e7aa2a77d9816e/ETjmsDbWmo1MmUeE_PLPNcgBr4Aj8ExR3l-k9qrw8hRvCw?e=4HeS2J
Checking the UI, Entry ID displayed in FF is 2288 and the post it links to has the WP ID 5521
For Entry ID 2287, the Post ID is 5520.
So it seems that the values being returned in the UI and in the script are the same.
Well, that explains why the delete isn't doing anything. I'm back to my theory that the entry you're looking at in Formidable is not what you think it is. I suggest searching the same table for ANY post_id that has "frm_display_id" as a meta value and reverse engineering it back to what your looking at in the front end. You can always file a support request with Strategy11 or hire a developer to look at it. https://formidable-masterminds.com/developers-directory/ I guess it's also possible the snippet is outdated and that's not how it works anymore.
Please login or Register to submit your answer