Forum Replies Created
-
AuthorPosts
-
Amy Schmidt
ParticipantHmm, there was a script written before I got here that converted cloned data to unserialized data into their custom fields. That could likely be causing some issues.
However, you did give me an idea I wish I thought of for debugging. Not sure why I didn't think of creating a test entry to play with that. I did that and saw all the ways I was updating PM wasn't inputting it correctly.
I did notice the correct PM serialized data was formatted just like above:
Array ( [0] => Array ( [available] => 2022-09-01 ) [1] => Array ( [available] => 2022-10-05 ) )So I just tried a non-loop basic
update_post_meta($id, 'field', $array)
and poof, updated properly! I was overthinking it.
And now to do some fun (sarcasm) stuff like adding extra features through javascript that the former dev hardcoded into the metabox files. I don't think there are any hooks for that, but I'll make it work.
Thanks for your help!
Amy Schmidt
ParticipantI was worried you were going to say that, so I thought of an alternative. Seeing as there are only a few fields that will be forced to remain the same until review (2-3 out of 30 or so fields), what I may do is just:
- Save changes to a new table
- Overwrite current table with old data for the 3 fieldsIf changes are approved, overwrite the live table with the changes
So basically, as a workaround, it'll change it and then instantly revert back to old all in same save. Is that ideal? No. But it is better than re-writing a frontend dashboard without metabox which would take significantly longer than this kludge lol
Amy Schmidt
ParticipantThank you, it has worked well. I do need one more thing, however.
Could you tell me how to stop the field from actually pushing to database? As I mentioned, I want to hold certain fields for review, so I tapped into 'rwmb_frontend_before_save_post' and have roughly this:
$old = rwmb_get_value($key, '', $id); $new = $_POST[$key]; if $old !== $new { // Here is where I want to take the field and push it off into it's own custom table but NOT save it to the live site. }Is there a command to prevent $new from saving if there is a change? Thanks!
Amy Schmidt
ParticipantSo, I did the after_save_post action with fields, and just got these fields:
` [fields] => Array
( [0] => post_title [1] => post_content [2] => post_excerpt [3] => post_date )Is there a way to access the actual custom fields on the frontend submission?
Amy Schmidt
ParticipantHi Peter, thank you. It would have to be the latter because some fields will be allowed to process. I'll check out those hooks ๐
Oh, and the save-to part is fairly important as well. I am using custom tables. When a change is approved, do I just push it to the custom table field, or do I also need to push it to any WordPress tables like wp_postmeta?
Thanks!
Amy Schmidt
ParticipantOkay, I did some testing with ACF/Hookturn Custom Tables and MB and this is what I found (please tell me if correct)
When a new custom entry is created, here is how it's added:
ACF/Hookturn - wp_posts, wp_customtable, wp_postmeta
MB - wp_posts, wp_customtableWhich is great! That secures MB is far and away better than ACF with Hookturn's custom field add-on. They literally duplicate the data for every entry while Metabox doesn't. So, compliments there!
Based on that, if I did create the custom frontend, I would indeed have to talk to wp_posts a little - at the very least for the 'post_updated' field. But it also does look like there are enough hooks for mb-frontend to accomplish the things I need. Being able to add classes to the table allow me to design it however I want.
I am going through an audit of the site right now to see exactly what needs to be done, but I think using mb-frontend may be a good solution. Regardless, I'll be sticking with MB for the rebuild so I'll be bugging you for more support in the future ๐
Amy Schmidt
ParticipantFirst question -
So to clarify, if I have a custom table named: wp_locations and did an INSERT from the frontend, wordpress would recognize it and I can see it on the CPT screen for Locations, delete it, clone it, integrate it with things like admincolumnspro etc?Second question -
Regarding the front end form, I tried using it, but Iโd like a little more customization when it comes to it. Perhaps I can write up a few things I actually do need and post it to the forum to see if there are hooks available?Right now the previous dev just hardcoded the stuff right into the plugin code which obviously gets erased on update. So I need to do things like flag fields for review (so admin can approve changes) and other custom features.
Iโm not looking for custom work done, but if I told you the things needed, could you point me in the right direction with hooks and if it can be done at all (without editing core files)?
Thank you!
Amy Schmidt
ParticipantHas this not been updated yet? It is still not working in the blocks
Amy Schmidt
ParticipantThank you. I'll be working on it this week and I'll let you know!
The person who coded this site before me hardcoded all these changes in the core metabox files so I'm looking to convert them to hooks so they don't disappear every update ๐
Amy Schmidt
ParticipantAhh, I read that wrong initially.
After messing with the actual data, it did simply show as an array when I pulled it out which was fine. I am probably going to avoid doing many WP_Query lookups anyway at this point because it's just easier for me to do a wpdb->get than trying to navigate WordPress' WP_Query formula.
Perhaps I'll watch some WP_Query videos later on to fully understand how that works. I'm sure WP has built-in caching with that (unless I'm wrong?) but it was a nightmare trying to figure it all out.
Between the serialized data and the issue I had here (https://support.metabox.io/topic/getting-all-data-from-relationship/) it was just quicker to do a LEFT JOIN and pull the fields I needed ๐ I know that's not the 'WP proper' way to do it, but definitely easier.
Amy Schmidt
ParticipantYea you can close this. The helper worked, I must have just been typing something wrong when I first tried.
Amy Schmidt
ParticipantAfter doing a bunch of reading here, I think this may have the solution I need.
https://metabox.io/mb-views-how-to-display-relationships/
I guess the answer is to just use a helper. I thought I tried the php version of it and it didnโt work but Iโll try again and mess around. Maybe I had a typo
-
AuthorPosts