Support Forum ยป User Profile

Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • in reply to: โœ…How to get the table name given the field_id #18053
    COMCEPTCOMCEPT
    Participant

    Thank you,
    we have the AIO plugin.
    Could you update that as well?

    in reply to: Relationship translations #18014
    COMCEPTCOMCEPT
    Participant

    Thanks Anh,

    That'd be great! We'd be able to grab the non-translated term/post, get the translation via polylang, and then create a new relationship with the new IDs so we'd be able (in theory) to automatically see it selected as the correct option in the relationship select.

    If that's possible, it's a very welcomed improvement! ๐Ÿ™‚

    in reply to: โœ…How to get the table name given the field_id #18013
    COMCEPTCOMCEPT
    Participant

    Thanks Anh, of course I can tell ๐Ÿ™‚

    So we have these custom post-types and they all share common data; we then decided to store this shared data in a common custom table and some specific data in their respective post-type-specific custom tables.

    We're hooking into the get_post_metadata and the add_post_metadata so that we can generalize the usage of the custom table plugin and render it "transparent" to other plugins such as Polylang.

    To do so we need to programmatically get the source/destination table, given a meta-key, where we need to retrieve/store its value.

    Let's focus on writing data (because we just join the shared/common meta-data table upon reading so it's simpler).

    Our meta writing function, in pseudo-code, looks more or less like this

    
    add_filter('add_post_metadata',   function ( $check, $object_id, $meta_key, $meta_value, $unique ){
       
            if this_is_not_a_custom_post_type || the_meta_key_is_not_a_metabox_field
                return null;
    
            // This is where we select the table, based on the field_id/meta_key
            $table = com_get_obj_property( rwmb_get_field_settings( $meta_key, '', $object_id )['storage'], 'table' );
    
            // This is so we update an existing ID in the custom table afterwards
            maybe_insert_id_in_custom_meta_table( $object_id, $table );
    
            // Maybe we need to serialize the value
            if ( !empty($meta_value) )
                $meta_value = maybe_serialize( $meta_value );
    
            // Finally write the correct meta value in the correct table updating the correct ID
            $wpdb->update( $table, [$meta_key => $meta_value], ['ID' => $object_id] );
        });
    

    As you can see, we dynamically need to grab the correct table based on the meta_key. That's why we'd need to have access to it (and we have, via the array casting trick).

    A simple getter, would be enough. No need to have a setter or make it public.

    in reply to: Relationship translations #17999
    COMCEPTCOMCEPT
    Participant

    Hi Anh,

    We're using Polylang Pro

    in reply to: Missing 'Link field' #17974
    COMCEPTCOMCEPT
    Participant

    Hi Ahn,
    is it possible to have an estimate of the release date?
    I'm switching to Meta Box on several projects and I need to migrate ACF link field to something similar.
    Thanks

    in reply to: โœ…Hooking into get_post_metadata and add_post_metadata #17865
    COMCEPTCOMCEPT
    Participant

    Thank you Anh,

    I was hoping for some sort of higher level approach; an API responsible for retrieving/storing metadata from/to custom tables (for a specific post id) with some kind of validation, sanitization, serialization and so on. Maybe a set of functions/wrappers to take into account the way Meta Box stores the fields. Is this low-level approach the only possible one?

    Thank you

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