Support

Account

Home Forums General Issues Is it possible to pass a date from one options page to another?

Unread

Is it possible to pass a date from one options page to another?

  • Hi,

    I have been banging my head on the desk for a week now trying to figure this out.

    I have a site that has numerous options pages. On one options page (Trade Show Details) the start and end dates for a trade show are entered.
    On a second options page show attendees are entered along with their arrival date. Is it possible to pass the show start date from the first details options page to the date field in the attendee options page and auto populate it so if it needs to be adjusted it’s relative to the actual show date. Not today’s date.

    I’ve tried using acf/load_field, acf/load_value and acf/update_value with no success.

    My thinking was when a new repeater row is added for a new attendee the value of the date isn’t set, so if that’s empty set it to the date of the show, but if it’s an existing entry leave it as it was.

    Here’s the avenue I’ve been going down with no success. Is it even possible?

    //set default date
    function my_acf_load_start_date( $value, $field, $post_id ) {
    
    if(get_field('btg_active_show_dates', 'option')):
    	while(has_sub_field('btg_active_show_dates', 'option')):
      	$defaut_show_start_date = get_sub_field('btg_show_opens');
    	$defaut_show_end_date = get_sub_field('brt_show_closes'); 
        endwhile; 
    	endif; 
    	//echo $defaut_show_start_date;
    	
    if($value == '') {
      $value = $defaut_show_start_date;
    }
    
     return $value;
    }
    add_filter('acf/update_value/key=field_526996739171c', 'my_acf_load_start_date', 10, 3);

    Am I going down the right road? Is this possible?

    Thanks,

    Sandra

Viewing 1 post (of 1 total)

The topic ‘Is it possible to pass a date from one options page to another?’ is closed to new replies.