Forums Forums Search & Filter Pro Can I filter fields in custom table created outside WP core oltables?

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #230230

    Hello,

    I am using ACF Custom Database Tables plugin that creates custom tables for ACF custom meta data. ACF Custom Database Tables uses ACF’s core API functions – get_field() and update_field() – to store/retrieve data from custom tables.

    The fields for the Custom Post Type are created as usual with ACF, but then the plugin saves the data in a custom table, outside the normal WP post meta table.

    I was wondering if I can use the SF Pro plugin for searching and filtering this custom table, maybe by altering the WP_Query?
    The custom fields do not appear in the Post Meta table at all, and also not in the SF post meta search field.

    Regards!

    Ross Moderator
    #230237

    Hi Alex

    Hmmm, I’m not sure if this will work.

    When we build the cache, we will use get_post_meta to retrieve the ACF values for the posts we cache.

    Do those plugins, intercept get_post_meta and perform the lookups on their own tables? Or do you need to use specific ACF functions to retrieve the data associated with a post?

    Thanks

    Anonymous
    #230239

    The plugin doesn’t use get_post_meta function, it retrieves data by using the ACF API (actions and filters) and ACF get_field(). There is no data saved in the wp_postmeta table.
    That’s why I was thinking of intercepting the WP_Query somehow…

    Ross Moderator
    #230246

    Hi Alex

    Ok so the issue I think is, when we build the cache of all the posts (a long query capturing all possible posts), we check meta_key and use get_post_meta, to store a copy of the value in our tables.

    Editing the actual query won’t be possible, because we’ve set suppress_filters to true on that particular query so there is no way of intercepting it.

    In addition, that doesn’t change how we then process the results, as we’re calling get_post_meta using the keys from the search form…

    In the next major version, we will be allowing indexing of custom tables, and custom processing filters on our caching process to change how certain values are handled / stored (so you could replace get_post_meta.

    Of course this is not a solution for you right now, but I did think of one possible work around:
    https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/
    https://wordpress.stackexchange.com/questions/121679/how-to-hook-a-filter-to-catch-get-post-meta-when-alternate-a-custom-field-output

    I think with this you can intercept a call to a specific meta key, and return a different value, basically using the the ACF API to retrieve the correct value, so our call to get_post_meta would get the correct value in the end and store in our tables (this is of course completely untested)…

    Let me know how you get on.

    Thanks

    Anonymous
    #230248

    Thanks! I’ll give it a try!
    Also, waiting for the updated version of your plugin!
    Regards! 🙂

    Anonymous
    #276857

    Hi,

    I have a generally similar configuration. For my part, my CPTs are saved in different tables to optimize queries as much as possible because I have a lot of data.

    You were talking about a major development allowing custom tables to be intercepted in January 2020. Is there anything new in this regard?

    Thanks in advance

Viewing 6 posts - 1 through 6 (of 6 total)