Support

Account

Forum Replies Created

  • Not sure if this helps, but I’m doing something similar, and I just created a quick multi-dimensional array which maps the field keys and the values from my form on the front-end to the proper variables, then I can use a loop. I’m using Gravity Forms, but here’s some (brief) sample code:

    //Map the Custom Field Keys
    $selections['furnace']['key'] = 'field_5181b4065293c';
    $selections['ac']['key'] = 'field_5181c655cb339';
    $selections['filter']['key'] = 'field_5181c6e3cb33d';
    	
    //Map the values to the proper entry vars
    $selections['furnace']['value'] = $entry['1'];
    $selections['ac']['value'] = $entry['2'];
    $selections['filter']['value'] = $entry['3'];
    		
    //See if there is any previously saved data, and save the new values
    foreach ($selections as $snippet=>$item) {
    			
    	if (strlen($item['value'] > 1)) { //Don't need to do anything unless we have a value to save
    			
    		//We don't care in this case if there was a previous value; we always replace it with any passed data
    		update_field( $item['key'], $item['value'], $post_id );
    	}
    }
  • I was able to solve the issue and move on with my life by using the built-in WordPress function get_post_meta()

    http://codex.wordpress.org/Function_Reference/get_post_meta

    Not as nice as working with get_field() and the_field(), but at least it’s reliable in a Network situation.

    Hope that helps!

  • Just an update – I tried to do this without any Gravity Forms code at all to see if that might be the problem – I just created a simple form in one page template and submitted it to another page, with a template to process the form. Still no dice. I’m thinking this is a conflict with switch_to_blog() and update_field()

    $channel_blog = $_POST['channel_blog'];
    $event_id = $_POST['event_id'];
    $win_loss = $_POST['win_loss'];
    $our_score = $_POST['our_score'];
    $opponent_score = $_POST['opponent_score'];
    	  	
    //Switch to the school's blog 
    switch_to_blog($channel_blog);
    		
    update_field('field_5215741f54e1f', $win_loss, $event_id ); // Win/Loss
    update_field('field_5215744854e20', $our_score, $event_id ); // Our Score
    update_field('field_5215746754e21', $opponent_score, $event_id ); // Opponent Score
    		
    // Restore Original Post Data
    restore_current_blog();
  • You have to use the new repeater field code. while_has_subfield is deprecated…

     
    // check if the repeater field has rows of data
    if( have_rows('repeater_field_name') ):
     
     	// loop through the rows of data
        while ( have_rows('repeater_field_name') ) : the_row();
     
            // display a sub field value
            the_sub_field('sub_field_name');
     
        endwhile;
     
    else :
     
        // no rows found
     
    endif;
    
  • Indeed you are correct. Sorry for the hassle!

  • It just doesn’t work. The data doesn’t load at all for fields created in the functions.php file after I’ve switched blogs. (Fields created in Admin interface work just fine, even after switch_to_blog).

    I had to use the old get_post_custom and get_option functions to get data to load after a switch_to_blog call, which is fine, but this is pretty unexpected behavior for the plugin that could potentially break multi-sites installations that rely on your plugin. Seems like it should work whether the field is created via PHP in the theme or through the plugin interface in the Admin.

    Thanks for the awesome plugin, and I hope this helps clarify.

  • I see that re-creating the fields using the plugin’s interface solved this problem for Full Circle Design. However, I have a Multi-Sites setup which has one main site and 25 satellite sites (and growing) which all will feed certain data into the main site. The satellite sites need to be setup quickly and the same way every time, so I need the fields to be created in the functions.php file. However I still need to access the field values from the main site, using switch_to_blog and a custom WP_Query.

    Elliot, do have any suggestions for how I can access the custom field data in this situation?

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