• Resolved aaronsnow

    (@aaronsnow)


    Hi,

    I’m using the Advanced Custom Fields plugin to add a custom field to EM’s “Event” custom post type. For single-value fields it works great, but when I add a Relationship field — or any type of field where you can select multiple values — the Edit Event admin page appears not be saving the changes.

    I say “appears” because I looked at the raw data in the wordpress_postmeta table, and the data is actually intact — but it’s been serialized twice instead of once:

    meta_value = s:34:”a:2:{i:0;s:3:”282″;i:1;s:3:”710″;}”;
    unserialize(meta_value) = a:2:{i:0;s:3:”282″;i:1;s:3:”710″;}
    unserialize(unserialize(meta_value)) = Array ( [0] => 282, [1] => 710 )

    Any idea what might be going on? I have no idea whether the “fault” lies with EM or ACF. I’ve cross-posted in the ACF forum as well, but if you have any insight it would be much appreciated.

    Thanks in advance,
    Aaron

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter aaronsnow

    (@aaronsnow)

    FWIW, I have custom attributes turned off in EM, because of the “deprecated attributes” issue. I’m trying to use ACF instead (because the UI is so much more flexible/palatable to our client).

    Thread Starter aaronsnow

    (@aaronsnow)

    Events Manager folks– any chance the following fix (or equivalent) could make it into your next rev?

    I’m pretty sure I’ve found the conflict between EM and ACF. In EM’s classes/em-event.php, at line 625-640 (in ver. 5.1.8.5), all post_meta fields get updated — even if you’ve disabled event attributes in Settings. That’s the part that’s causing the conflict: EM is serializing the field, and ACF serializing it too, not imagining any other plugin would modify its fields.

    So here’s the fix: at line 629, I changed

    }elseif($key == 'event_attributes'){

    to

    }elseif($key == 'event_attributes' && get_option('dbem_attributes_enabled')){

    This way, if you choose not to enable EM’s attributes feature, then EM doesn’t assume all available post_meta to be attributes, and won’t do anything to them (e.g., unwanted serialization). This fix doesn’t let you use both EM’s attributes feature and other plugins’ custom fields, but that seems like a reasonable trade-off.

    Maybe for next ver release?

    Thank you …

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    I’ll add that as it should be that way, but not sure what you mean about serialized attributes, I don’t believe we do that anymore, we just save each attribute as a post custom field.

    We use update_post_meta/delete_post_meta and insert the raw data

    Thread Starter aaronsnow

    (@aaronsnow)

    Thanks, Marcus. The fix above makes this moot, but FWIW it looks like the serialization happens in function save_events(), same file, line 1681:

    $event['event_attributes'] = serialize($event['event_attributes']);

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    aha i see, that shouldn’t be used at all though, it’s remenants of version 4 when events weren’t custom post types. the values in that array are now single post meta values.

    does any adverse behaviour occur here, or is it just the fact that this field is serialized twice?

    Thread Starter aaronsnow

    (@aaronsnow)

    Hi- sorry for the lag. Yeah, the adverse behavior is that the twice-serialized values can’t be read by any other plugins that are expecting once-serialized values — which is what happened to me with ACF: I’d make some selections, click Update, and then when their control read the values back out of the field, it didn’t see anything it recognized, so the control wouldn’t re-populate.

    Aside from plugin conflicts, the values can’t be queried, either — at least not in the usual way.

    Anyway, thanks for the fix. It’ll save me the trouble of re-applying it with each upgrade. ??

    What fix are you talking about? This is still a problem on a clients site using the latest ACF and Events Manager plugin.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    I’ve never managed to reproduce ACF issues, so if you can, please start a new thread and describe how exactly you set up ACF to reproduce this.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Events Manager] conflict w/ Advanced Custom Fields: arrays getting "double-serialized&’ is closed to new replies.