WordPress.org

Ready to get started?Download WordPress

Forums

Exports and Reports
[resolved] Custom fields containing arrays (3 posts)

  1. collinp2@gmail.com
    Member
    Posted 1 year ago #

    Anybody got any ideas on how to extract values contained in a custom field array to use in a report?

    Here is the format, I've seen this format used in the wp-options table quite frequently:

    a:3:{s:5:"Notes";a:1:{i:0;s:91:"No longer interested. Decided the money was not available at this time or the near future.";}s:4:"Type";a:1:{i:0;s:10:"Phone Call";}s:4:"Date";a:1:{i:0;s:11:"Mar 6, 2013";}}

    http://wordpress.org/extend/plugins/exports-and-reports/

  2. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 1 year ago #

    In the fields settings, you can specify a display function to run through.

    Try setting it to "my_custom_serialize_display"

    and then add this code to your site:

    function my_custom_serialize_display ( $value, $row, $field, $attributes, &$obj ) {
        $data = maybe_unserialize( $value ) );
    
        if ( is_array( $data ) ) {
            // Do something with $data, and set $value
        }
    
        return $value;
    }
  3. collinp2@gmail.com
    Member
    Posted 1 year ago #

    Actually... I just figured this out...

    TRIM(BOTH '"' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(int_4_postmeta.meta_value, ';', 2), ':', -1))
              AS Notes,
           TRIM(BOTH '"' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(int_4_postmeta.meta_value, ';', 4), ':', -1))
              AS Type,
           TRIM(BOTH '"' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(int_4_postmeta.meta_value, ';', 6), ':', -1))
              AS Date

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic