Skip Navigation

[Résolu] After upgrade, meta data is different and field not displaying on front end

This support ticket is created Il y a 5 années et 8 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Marqué : 

This topic contains 4 réponses, has 2 voix.

Last updated by Stephen Il y a 5 années et 8 mois.

Auteur
Publications
#1091201

I am trying to:
Display a certain field in the front end that worked fine before the upgrade, and continues to work on any records not saved under the new version. But once they are saved, this field (but not others) disappears from the front end.

Link to a page where the issue can be seen:
You can't really see something that is NOT there, can you. But when I look in the DB at the values being submitted new vs old, I see several differences:

NEW type of value

a:1:{s:64:"wpcf-fields-checkboxes-option-077388262129e6eb58f7f436059c42d0-1";a:1:{i:0;s:4:"form";}}

OLD type of value

a:2:{s:64:"wpcf-fields-checkboxes-option-fec428a05f639e9f0bf499678fda2084-1";s:3:"top";s:64:"wpcf-fields-checkboxes-option-077388262129e6eb58f7f436059c42d0-1";s:4:"form";}

FYI, here is my template code that fails with the new values:

<?php echo do_shortcode('[wpv-if button="wpcf-button-text" evaluate="!empty($button)"]<div id="buttontext1"><span class="buttontext1">[types field="button-text" output="raw"][/types]</span></div>[/wpv-if]'); ?>

I expected to see: My fields on the front end

Instead, I got: nothing when any of these records has been updated.

#1091879

I am quite sure this is an issue when updating from a old Types version (more than a year) to something of the latest versions.
On top, it may be related to wether or not you migrated to the new Many To Many Relationships in Toolset > Relationships.

We had several issues, one of them (solved and won't fix) looks similar:
https://toolset.com/errata/checkboxes-set-to-save-0-if-empty-do-not-save-anything-if-they-are-updated-through-a-parent-post-and-not-checked/
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

I suspect your field if of such type (Checkboxes, that save 0 to the database)?

If so I recommend to change to a field that doesn't save 0.

However to solve the error you experience directly, I need a copy of the site before you upgraded, if you have that.
Then, I will install the update and see what happens, so to inform the developers.

If this is not possible, can you just send a (possibly slimmed down) copy of your site so we can have a look at what happens?

#1091917

Once I changed my (previously created) checkbox field to save 0 to the db and re-saved my posts, it is working again, thanks!!

#1091921

I need to modify my response because after some testing, I noticed that changing it to store 0 did NOT solve the problem. Here is what I found and what I had to change in my code, hoping it helps someone else.

Previously, I was getting the meta from the db and looking for my value in_array like so:

$butpos = get_post_meta(get_the_ID(), 'wpcf-button-pos', true );
if (in_array("top", $butpos)) { 

The problem with this was that after the upgrade, that value was no longer stored at the top level, it was stored a level down now. So I changed my code to this:

$butpos = get_post_meta(get_the_ID(), 'wpcf-button-pos', true );
$thisval = array_shift($butpos);
if (in_array("top", $thisval)) { 

And voila! now it works as before. Thanks anyway for the help, it did point me in the right direction and from there I was able to solve the problem.

#1091922

had to re-open ticket to add comment, now re-closing again since I fixed it.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.