Support

Account

Home Forums Feedback Suggestion for update_field() doc

Unread

Suggestion for update_field() doc

  • When updating a blank repeater field you’ll receive a PHP Fatal error: [] operator not supported for strings

    To get around this –

    $field_key = "field_123456789";
    $post_id = "user_" . $user_id;
    
    if ( get_field($field_key, $post_id) ){
    	$value = get_field($field_key, $post_id);
    } else {
    	$value = array();
    }
    
    $value[] = array("hours" => $enrolled_class, "date" => $stripe_date);
    	
    update_field( $field_key, $value, $post_id );
Viewing 1 post (of 1 total)

The topic ‘Suggestion for update_field() doc’ is closed to new replies.