Support

Account

Home Forums Backend Issues (wp-admin) PHP Generated fields not being stored

Helping

PHP Generated fields not being stored

  • TLDR;
    I’m promoting a staging site to production, both on the same hosting provider but the production site will not save the PHP registered fields in the production data base.

    Long Version
    I am migrating a staging site to production. It includes the Polylang plugin (as I’ve mentioned in previous tickets). I had a handful of errors with Polylang as some theme files were migrated *before* the plugin was on the site. Once I was able to resolve this issue I was able to confirm the PHP Registered Field Groups were displaying within the Option Page on production.

    The Field Group(s) in question are post-object groups. When attempting to select a post to include into the post-object input I received an error message “Loading error” or something of the like. It displayed in the dropdown area where posts would otherwise display (I’ve since rolled back the production site so I do not have a screenshot).

    After poking around a bit I went and searched in FlyWheel’s Database to see if the fields were saved and they were unable to be found in the options table in the WordPress Database.

    It may be a stretch to ask you, as you aren’t the FlyWheel but curious if you’ve seen any issue like this before or know of any steps to help resolve the issue? I’m also reaching out to FlyWheel too.

    For posterity I’ll add the code to register fields via PHP

    if ( defined( 'POLYLANG_VERSION' ) && class_exists('acf')  ) {
    	// Create a field group for our ACF field to be inserted into. 
    	// It's basically the visual wrapper for the field. 
    	function pt_create_acf_local_field_group($group_key, $title) {
    		acf_add_local_field_group(array (
    			'key' => $group_key,
    				'title' => $title,
    				'location' => array (
    					array (
    						array (
    							'param' => 'options_page',
    							'operator' => '==',
    							'value' => 'acf-options',
    						),
    					),
    				),
    			'menu_order' => 0,
    			'position' => 'normal',
    			'style' => 'default',
    			'label_placement' => 'top',
    			'instruction_placement' => 'label',
    			'hide_on_screen' => '',
    			
    		));
    	}
    
    	// Dymanically generates our field(s)
    	function pt_create_acf_local_field($key, $label, $name, $tax, $parent) {
    		var_dump($tax);
    		acf_add_local_field( array(
    			'key' => $key,
    			'name' => $name,
    			'type' => 'post_object',
    			'parent' => $parent,
    			'post_type' => 'post',
    			'multiple' => 1,
    			'taxonomy' => array('language:'. $tax),
    			'min' => 0,
    			'max' => 3,
    			'instructions' => 'Select items from here to feature in the "feature" area (top section) of the home ' . strtoupper( $tax ) . ' page.',
    			'return_format' => 'object',
    		));
    	}
    
    	if( function_exists('acf_add_local_field') && function_exists( 'acf_add_local_field_group' )  ) {
    
    		if ( function_exists('pll_languages_list') ) {
    
    			$pl_languages = pll_languages_list();
    
    			foreach ($pl_languages as $key => $value) {
    				$group = 'group_' . $key . '_lang_' . $value;
    				$groupTitle = strtoupper( $value ) . ' Featured Posts';
    
    				$key = 'field_lang_' . $value;
    				$label = $value;
    				$name = 'featured_lang_' . $value;
    
    				pt_create_acf_local_field($key, $label, $name, $value, $group);
    				pt_create_acf_local_field_group($group, $groupTitle);
    			}
    		}
    	}
    }
  • Hi @patrickbjohnson

    Thanks for the post.

    I have certainly not run into this issue before.

    Please open a new support ticket via [email protected] with some temporary admin access to your site and a link to this thread so that we can help in diagnosing this.

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

The topic ‘PHP Generated fields not being stored’ is closed to new replies.