Support

Account

Home Forums General Issues Catchable fatal error – stdClass could not be converted to string

Helping

Catchable fatal error – stdClass could not be converted to string

  • Catchable fatal error: Object of class stdClass could not be converted to string in /advanced-custom-fields/core/api.php on line 23

    function get_field_reference($field_name, $post_id ) {

    // cache
    $found = false;
    —LINE-23 $cache = wp_cache_get( ‘field_reference/post_id=’ . $post_id . ‘/name=’ . $field_name, ‘acf’, false, $found );

    if( $found )
    {
    return $cache;
    }

    // vars
    $return = ”;

    // get field key
    if( is_numeric($post_id) )
    {
    $return = get_post_meta($post_id, ‘_’ . $field_name, true);
    }
    elseif( strpos($post_id, ‘user_’) !== false )
    {
    $temp_post_id = str_replace(‘user_’, ”, $post_id);
    $return = get_user_meta($temp_post_id, ‘_’ . $field_name, true);
    }
    else
    {
    $return = get_option(‘_’ . $post_id . ‘_’ . $field_name);
    }

    // set cache
    wp_cache_set( ‘field_reference/post_id=’ . $post_id . ‘/name=’ . $field_name, $return, ‘acf’ );

    // return
    return $return;
    }

  • Hi @faiswiz

    You might not be using the right variable to hold the object, it is also important to ensure that the object is instantiated before calling the function.

    For the correct usage of the function please refer to this article: https://codex.wordpress.org/Function_Reference/wp_cache_get

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

You must be logged in to reply to this topic.