Support

Account

Home Forums Backend Issues (wp-admin) Custom fields get emptied when publishing

Solved

Custom fields get emptied when publishing

  • Hi there,

    I have updated ACF this morning and my custom fields are not saved anymore when I publish a post.

    I have:
    – a true/false field (checked by default)
    – a text area with html format (conditional apears only when true is selected in the field above with a defaut value)
    – and a checkbox field, only one choice (coditional too with a default value)

    When I create a new post it looks fine, I have the box checked and the fields below it pre-filled. I write my post and change the value of those fields if needed.
    On preview, everything looks fine. but when i publih the post, The true/false field is unchecked and the two others are empty (not even the default value).

    I did several tests on different new posts, changing values of the fiels, not changing anything etc…
    I didn’t change my php template and the old posts are ok. I use a cache plugin but and purged all caches and modules. Still not working…

    If my php code in the single-post template wasn’t correct the old posts wshouldn’t work too? and why it’s working on preview but not on publish?

    Please can you tell me where should I have a look? I’m out of ideas…

    Thanks in advance

  • I have the same problem after updating to 4.1.7, when i create a post and publish it there is no problem, but when i try to edit a post after updating all the custom fields get emptied.
    There is a serious bug with the new version and for now i’m going to use the previous version. I couldn’t find the 4.1.6 but I’ve downloaded the 4.1.5 version here:
    https://github.com/elliotcondon/acf/releases

  • Hi Arash,

    You can download any version you want from here:
    http://wordpress.org/plugins/advanced-custom-fields/developers/

  • Hi there, first off Elliot you have created a top notch plugin here. I couldn’t imagine not having it.

    I recently updated to version 4.1.7. When I did my relationship fields show up as being empty. When I try to update the page and publish, the field entry disappears.

    I tried going back to version 4.1.6 and 4.1.5 with no luck.

    Thanks in advance for your help.

  • Hi guys,

    I’ll be looking into this shortly.

    In the meantime, are you able to help out with this issue?

    Please upgrade to v4.1.7 and edit the ‘core/controllers/input.php’ save_post function. Some simple debugging will reveal why the acf/save_post action is not being run. Perhaps one of the if statements is failing?

  • Hi @philsandoval

    This topic has already been started in another thread. I’ll merge it over to the new location

  • I believe this is the same problem as the one I reported in the old support forum.

    As i mentioned, when I publish the post

    A) update_value() receives the value,

    B) data is stored in “prefix”_postmeta table:

    select * from dev_postmeta where meta_key = 'dato' ORDER BY meta_id DESC LIMIT 1;

    returns the correct value in meta_value (‘dato’ is the field name)

    select * from dev_postmeta where meta_key = '_dato' ORDER BY meta_id DESC LIMIT 1;

    returns the correct field_”number” in meta_value

    C) create_field() creates an empty field on reload after the publish post

  • I’m experiencing the same problem, and I’ve down installed v4.1.6 after updating. Everything in v4.1.6 works like a charm.

    I’m not sure if it’s a problem with core/controllers/input.php — I’ve used the plugin in 4.1.7 with the input.php code the same from v.4.1.6 and this not-saving clearing problem still occurs.

  • Been xdebugging, and maybe this helps. core/fields/_functions.php:load_field( $field, $field_key, $post_id = false ) returns:

    $f = array[18]
    	$f['name'] = (string) dato
    	$f['class'] = (string) date_time_picker
    	$f['time_format'] = (string) H:mm
    	$f['field_group'] = (int) 6583
    	$f['conditional_logic'] = array[3]
    		$f['conditional_logic']['allorany'] = (string) all
    		$f['conditional_logic']['rules'] = array[1]
    			$f['conditional_logic']['rules'][0] = array[2]
    				$f['conditional_logic']['rules'][0]['operator'] = (string) ==
    				$f['conditional_logic']['rules'][0]['field'] = (string) null
    		$f['conditional_logic']['status'] = (int) 0
    	$f['show_week_number'] = (string) false
    	$f['value'] = <string>
    	$f['required'] = (int) 0
    	$f['type'] = (string) date_time_picker
    	$f['id'] = (string) acf-field-dato
    	$f['key'] = (string) field_51d520b7091da
    	$f['label'] = (string) dato
    	$f['picker'] = (string) slider
    	$f['show_date'] = (string) true
    	$f['order_no'] = (int) 0
    	$f['instructions'] = <string>
    	$f['save_as_timestamp'] = (string) true
    	$f['date_format'] = (string) m/d/y

    As you can see, the $f[‘value’] is empty

  • I have the same issue. I wonder, do you all have Events Calendar Pro by Modern Tribe installed? I have downgraded and reverted WordPress and plugins needing to be upgraded to the last stable set. I’ve identified that when I upgrade the events calendar to the latest version, it wipes all relationships clear in ACF.

    Reverting The Events Calendar to Version 2.0.11 fixes the issue.

  • Hi guys.

    Thanks for the info.

    A few other topics today have highlighted an issue with the new cahce parameters I introduced in the 4.1.7 build.

    These new parameters were to better handle cache detection but seem to be causing PHP errors!

    Can you please turn on DEBUG MODE in your wp-config.php and try to load a page? I think the php error is causing the save function to fail, or the load function to fail… on or the other.

    I’ll do some more testing today and find a fix

  • I’ve just pushed an update to github containing a fix for this cache issue.

    Can you please update to the latest nightly build and let me know how it goes?

  • Updated to 4.1.8, but still no luck (debug is on and doesn’t report any errors)

    I installed Debug Objects, and for ‘Post Type & Meta’, when I’m opening a post in edit mode, it shows:

    
    Post ID: 6632
    Meta Keys: 8
    Key				Value
    _edit_last
    1 value	
    				array (
    				  0 => '1',
    				)
    _edit_lock
    1 value	
    				array (
    				  0 => '1373360374:1',
    				)
    dato
    1 value	
    				array (
    				  0 => '1373500800',
    				)
    _dato
    1 value	
    				array (
    				  0 => 'field_51d520b7091da',
    				)
    repeat
    1 value	
    				array (
    				  0 => '1',
    				)
    _repeat
    1 value	
    				array (
    				  0 => 'field_51da7b12dbf99',
    				)
    repeat_0_dato2
    1 value	
    				array (
    				  0 => '1373414400',
    				)
    _repeat_0_dato2
    1 value	
    				array (
    				  0 => 'field_51da7b24dbf9a',
    				)
    

    value for ‘dato’ isn’t displayed in the custom field, but value for ‘repeat_0_dato2’ is displayed

  • Hi @pers

    Can you please re-download v4.1.8 and make sure that the acf.php file (save_post function) does not reference any $GLOBALS items?

    I have a feeling you have a version of 4.1.8 which still contains the issue.

  • I believe I have the latest. acf.php:save_post() looks like this:

    	function save_post( $post_id )
    	{
    
    		// load from post
    		if( !isset($_POST['fields']) )
    		{
    			return false;
    		}
    		
    
    		// loop through and save
    		if( !empty($_POST['fields']) )
    		{
    			// loop through and save $_POST data
    			foreach( $_POST['fields'] as $k => $v )
    			{
    				// get field
    				$f = apply_filters('acf/load_field', false, $k );
    				
    				// update field
    				do_action('acf/update_value', $v, $post_id, $f );
    				
    			}
    			// foreach($fields as $key => $value)
    		}
    		// if($fields)
    		
    		
    		return true;
    	}
    
  • I had the same issue with a Date and time picker field. It updates in the database but text input gets emptied after updating a post in the backend. My field is a conditionnal field. I have other fields of the same type innside repeaters and they work fine in 4.1.7… I had to downgrade to version 4.1.4 in order to get it to work and now it’s fine.

  • Was it my Date and Time Picker field you tested?

  • Ignore my previous question, I can confirm that Date and Time Picker field works fine in ACF v4.1.4

    Thank you dominic 🙂

  • Hi @pers

    Yep, that looks correct. Are you reporting that this is not running?

    Have you been able to do some simple debugging in that function to make sure it is working?

  • save_post() works fine in 4.1.8, and doesn’t create any errors. Here’s XDebug Context for ACF 4.1.8 , breakpoint at $f = apply_filters('acf/load_field', false, $k ); in acf.php:save_post( $post_id )

    Inside the loop, 1st iteration (single date and time picker field):

    
    $f = array[18]
    	$f['name'] = (string) dato
    	$f['class'] = (string) date_time_picker
    	$f['time_format'] = (string) H:mm
    	$f['field_group'] = (int) 6583
    	$f['conditional_logic'] = array[3]
    		$f['conditional_logic']['allorany'] = (string) all
    		$f['conditional_logic']['rules'] = array[1]
    			$f['conditional_logic']['rules'][0] = array[2]
    				$f['conditional_logic']['rules'][0]['operator'] = (string) ==
    				$f['conditional_logic']['rules'][0]['field'] = (string) null
    		$f['conditional_logic']['status'] = (int) 0
    	$f['show_week_number'] = (string) false
    	$f['value'] = <string>
    	$f['required'] = (int) 0
    	$f['type'] = (string) date_time_picker
    	$f['id'] = (string) acf-field-dato
    	$f['key'] = (string) field_51d520b7091da
    	$f['label'] = (string) dato
    	$f['picker'] = (string) slider
    	$f['show_date'] = (string) true
    	$f['order_no'] = (int) 0
    	$f['instructions'] = <string>
    	$f['save_as_timestamp'] = (string) true
    	$f['date_format'] = (string) m/d/y
    $v = (string) 7/11/13 7:00
    $post_id = (int) 6640
    $k = (string) field_51d520b7091da
    $this = Acf[1]
    	$this->settings = array[5]
    		$this->settings['path'] = (string) /Users/per/Sites/dev.local/wp-content/plugins/advanced-custom-fields/
    		$this->settings['dir'] = (string) http://dev.local/wp-content/plugins/advanced-custom-fields/
    		$this->settings['upgrade_version'] = (string) 3.4.1
    		$this->settings['hook'] = (string) advanced-custom-fields/acf.php
    		$this->settings['version'] = (string) 4.1.8
    

    Second iteration, date and timepicker field inside a repeater field

    
    $f = array[16]
    	$f['name'] = (string) repeat
    	$f['class'] = (string) repeater
    	$f['field_group'] = (int) 6583
    	$f['conditional_logic'] = array[3]
    		$f['conditional_logic']['allorany'] = (string) all
    		$f['conditional_logic']['rules'] = array[1]
    			$f['conditional_logic']['rules'][0] = array[3]
    				$f['conditional_logic']['rules'][0]['operator'] = (string) ==
    				$f['conditional_logic']['rules'][0]['field'] = (string) null
    				$f['conditional_logic']['rules'][0]['value'] = <string>
    		$f['conditional_logic']['status'] = (int) 0
    	$f['layout'] = (string) table
    	$f['row_min'] = (int) 0
    	$f['button_label'] = (string) Add Row
    	$f['sub_fields'] = array[1]
    		$f['sub_fields'][0] = array[18]
    			$f['sub_fields'][0]['label'] = (string) dato2
    			$f['sub_fields'][0]['name'] = (string) dato2
    			$f['sub_fields'][0]['value'] = <string>
    			$f['sub_fields'][0]['key'] = (string) field_51da7b24dbf9a
    			$f['sub_fields'][0]['instructions'] = <string>
    			$f['sub_fields'][0]['save_as_timestamp'] = (string) true
    			$f['sub_fields'][0]['column_width'] = <string>
    			$f['sub_fields'][0]['order_no'] = (int) 0
    			$f['sub_fields'][0]['id'] = (string) acf-field-dato2
    			$f['sub_fields'][0]['picker'] = (string) slider
    			$f['sub_fields'][0]['class'] = (string) date_time_picker
    			$f['sub_fields'][0]['time_format'] = (string) h:mm tt
    			$f['sub_fields'][0]['type'] = (string) date_time_picker
    			$f['sub_fields'][0]['show_week_number'] = (string) false
    			$f['sub_fields'][0]['show_date'] = (string) true
    			$f['sub_fields'][0]['required'] = (int) 0
    			$f['sub_fields'][0]['date_format'] = (string) m/d/y
    			$f['sub_fields'][0]['conditional_logic'] = array[3]
    				$f['sub_fields'][0]['conditional_logic']['status'] = (int) 0
    				$f['sub_fields'][0]['conditional_logic']['rules'] = (int) 0
    				$f['sub_fields'][0]['conditional_logic']['allorany'] = (string) all
    	$f['required'] = (int) 0
    	$f['type'] = (string) repeater
    	$f['id'] = (string) acf-field-repeat
    	$f['key'] = (string) field_51da7b12dbf99
    	$f['label'] = (string) repeat
    	$f['order_no'] = (int) 1
    	$f['instructions'] = <string>
    	$f['row_limit'] = <string>
    $v = array[2]
    	$v['acfcloneindex'] = array[1]
    		$v['acfcloneindex']['field_51da7b24dbf9a'] = <string>
    	$v[1373458984969] = array[1]
    		$v[1373458984969]['field_51da7b24dbf9a'] = (string) 7/12/13 12:00 am
    $post_id = (int) 6640
    $k = (string) field_51da7b12dbf99
    $this = Acf[1]
    	$this->settings = array[5]
    		$this->settings['path'] = (string) /Users/per/Sites/dev.local/wp-content/plugins/advanced-custom-fields/
    		$this->settings['dir'] = (string) http://dev.local/wp-content/plugins/advanced-custom-fields/
    		$this->settings['upgrade_version'] = (string) 3.4.1
    		$this->settings['hook'] = (string) advanced-custom-fields/acf.php
    		$this->settings['version'] = (string) 4.1.8
    
    

    But I guess this is not really the issue. As said previously, the content exist in post meta but it’s not displayed/populated to the custom field.

    When I open a post, where (in ACF) is data read from post meta (ie, where should I set my breakpoints)?

  • Hi @pers

    ACF v4.1.8.1 has been released to address a few more bugs with the save function.

    Can you please update?

  • Updated to 4.1.8.1, but can’t see any difference

  • This reply has been marked as private.
  • Hi @mathias Gomig

    Are you saying that the only issue you are having is with a 3rd part field not saving?

    if so, you should contact the developer of the timepicker plugin.

  • This reply has been marked as private.
Viewing 25 posts - 1 through 25 (of 32 total)

The topic ‘Custom fields get emptied when publishing’ is closed to new replies.