Support

Account

Home Forums Front-end Issues Integrate ACF in "All-in-one Event Calendar"

Solving

Integrate ACF in "All-in-one Event Calendar"

  • Hi!

    I’m trying to use the wonderful ACF plugin together with “All-in-one Event Calendar” plugin (http://time.ly/).

    “All-in-one Event Calendar” has a post type called “a1ec_event” so in ACF I created a new custom field called “compilatore”, set the location to the post type “a1ec_event” and the custom field “compilatore” is correctly displayed between the “native” fields of a new post “Event” in the admin backend of WP.

    But All-in-one Event Calendar” plugin has also a frontend section in wich the logged users can fill the fields (title, venue, date, description etc) to create a new Event.

    A Div event is handled so in the “All-in-one Event Calendar” .php file:`
    <div class=”row-fluid”>
    <input type=”text” id=”ai1ec-event-title” name=”post_title”/>
    </div>`

    So, the plugin “reads” that user input a text in the input with id “”ai1ec-event-title” and save this text in the correspondant field in the admin backend.

    So, to make the same with my ACF custom field, I've tried to add:`
    <div class=”row-fluid”>
    <input type=”text” id=”compilatore” name=”post_title”/>
    </div>
    `

    But it doesn’t work. I’ve tried also with “id=”acf-field-ai1ec_compilatore” but it doesn’t work.

    My input custom field is displayed in the “All-one-event Calendar” frontend but the text the user inserts in is not saved.

    Any hint or suggestion? Where am I wrong?

    Thanks in advance for your attention!

    Davide

  • Hi!

    I’ve tried also with:

    	<?php 
     
    $field_key = "field_5265167430efd";
    $value = htmlentities($_GET['compilatore']); 
    update_field( $field_key, $value )?>
    	
    	<div class="row-fluid">
    		<input type="text" id="ai1ec_compilatore" name="compilatore"
    			
    			class="span12" />
    	</div>
    

    but it doesn’t work 🙁

  • Hi @Aminta

    Sorry, but I can’t offer any help on this one as I have no knowledge of this plugin or what you are trying to do with it.

    Have you contacted the dev of the ‘All in one event calendar’ to ask them how to extend the custom fields?

    Thanks
    E

  • Hi Elliot!

    Yes, yesterday I’ve contacted the developers of the plugin and I’m in wait of an answer.

    However, I thought that – to pass a value in a input box to update a custom field – it would be enough to use your APIs.

    It is only important to me that the text the user inserts will appear (in the backend) in the custom field I’ve created with ACF in event post.

    Let me know,

    Thanks!

    Davide

  • Hi Elliot!

    The developer of the plugin told me to insert the custom field created with Acf in the save_post function of the plugin. Here is the code, can you help me?

    function save_post( $post_id, $post ) {
    		global $wpdb, $ai1ec_events_helper, $ai1ec_importer_plugin_helper;
    
    		// verify this came from the our screen and with proper authorization,
    		// because save_post can be triggered at other times
    		if( isset( $_POST[AI1EC_POST_TYPE] ) && ! wp_verify_nonce( $_POST[AI1EC_POST_TYPE], 'ai1ec' ) ) {
    			return;
    		} else if( ! isset( $_POST[AI1EC_POST_TYPE] ) ) {
    			return;
    		}
    
    		if( isset( $post->post_status ) && $post->post_status == 'auto-draft' ) {
    			return;
    		}
    
    		// verify if this is not inline-editing
    		if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'inline-save' ) {
    			return;
    		}
    
    		// verify that the post_type is that of an event
    		if( isset( $_POST['post_type'] ) && $_POST['post_type'] != AI1EC_POST_TYPE ) {
    			return;
    		}
    
    		// LABEL:magicquotes
    		// remove WordPress <code>magical</code> slashes - we work around it ourselves
    		$_POST = stripslashes_deep( $_POST );
    
    		$all_day          = isset( $_POST['ai1ec_all_day_event'] )    ? 1                                             : 0;
    		$instant_event    = isset( $_POST['ai1ec_instant_event'] )    ? 1                                             : 0;
    		$start_time       = isset( $_POST['ai1ec_start_time'] )       ? $_POST['ai1ec_start_time']                    : '';
    		$end_time         = isset( $_POST['ai1ec_end_time'] )         ? $_POST['ai1ec_end_time']                      : '';
    		$venue            = isset( $_POST['ai1ec_venue'] )            ? $_POST['ai1ec_venue']                         : '';
    		$address          = isset( $_POST['ai1ec_address'] )          ? $_POST['ai1ec_address']                       : '';
    		
    		$compilatore            = isset( $_POST['ai1ec_event_1_nome_e_cognome_compilatore'] )            ? $_POST['ai1ec_event_1_nome_e_cognome_compilatore']                         : '';
    		
    		$city             = isset( $_POST['ai1ec_city'] )             ? $_POST['ai1ec_city']                          : '';
    		$province         = isset( $_POST['ai1ec_province'] )         ? $_POST['ai1ec_province']                      : '';
    		$postal_code      = isset( $_POST['ai1ec_postal_code'] )      ? $_POST['ai1ec_postal_code']                   : '';
    		$country          = isset( $_POST['ai1ec_country'] )          ? $_POST['ai1ec_country']                       : '';
    		$google_map       = isset( $_POST['ai1ec_google_map'] )       ? 1                                             : 0;
    		$cost             = isset( $_POST['ai1ec_cost'] )             ? $_POST['ai1ec_cost']                          : '';
    		$is_free          = isset( $_POST['ai1ec_is_free'] )          ? (bool)$_POST['ai1ec_is_free']                 : false;
    		$ticket_url       = isset( $_POST['ai1ec_ticket_url'] )       ? $_POST['ai1ec_ticket_url']                    : '';
    		$contact_name     = isset( $_POST['ai1ec_contact_name'] )     ? $_POST['ai1ec_contact_name']                  : '';
    		$contact_phone    = isset( $_POST['ai1ec_contact_phone'] )    ? $_POST['ai1ec_contact_phone']                 : '';
    		$contact_email    = isset( $_POST['ai1ec_contact_email'] )    ? $_POST['ai1ec_contact_email']                 : '';
    		$contact_url      = isset( $_POST['ai1ec_contact_url'] )      ? $_POST['ai1ec_contact_url']                   : '';
    		$show_coordinates = isset( $_POST['ai1ec_input_coordinates'] )? 1                                             : 0;
    		$longitude        = isset( $_POST['ai1ec_longitude'] )        ? $_POST['ai1ec_longitude']                     : '';
    		$latitude         = isset( $_POST['ai1ec_latitude'] )         ? $_POST['ai1ec_latitude']                      : '';
    		$post_twitter     = isset( $_POST['ai1ec_oauth_provider_twitter'] )
    			? (bool)$_POST['ai1ec_oauth_provider_twitter']
    			: false;
    
    		$rrule  = NULL;
    		$exrule = NULL;
    		$exdate = NULL;
    
    		// if rrule is set, convert it from local to UTC time
    		if( isset( $_POST['ai1ec_repeat'] ) && ! empty( $_POST['ai1ec_repeat'] ) )
    			$rrule = $ai1ec_events_helper->ics_rule_to_gmt( $_POST['ai1ec_rrule'] );
    
    		// if exrule is set, convert it from local to UTC time
    		if (
    			isset( $_POST['ai1ec_exclude'] ) &&
    			! empty( $_POST['ai1ec_exclude'] ) &&
    			NULL !== $rrule // no point for exclusion, if repetition is not set
    		) {
    			$exrule = $this->_merge_exrule(
    				$_POST['ai1ec_exrule'],
    				$_POST['ai1ec_rrule']
    			);
    			$exrule = $ai1ec_events_helper->ics_rule_to_gmt( $exrule );
    		}
    
    		// if exdate is set, convert it from local to UTC time
    		if( isset( $_POST['ai1ec_exdate'] ) && ! empty( $_POST['ai1ec_exdate'] ) )
    			$exdate = $ai1ec_events_helper->exception_dates_to_gmt( $_POST['ai1ec_exdate'] );
    
    		$is_new = false;
    		$event 	= null;
    		try {
    			$event = new Ai1ec_Event( $post_id ? $post_id : null );
    		} catch( Ai1ec_Event_Not_Found $e ) {
    			// Post exists, but event data hasn't been saved yet. Create new event
    			// object.
    			$is_new = true;
    			$event = new Ai1ec_Event();
    			$event->post_id = $post_id;
    		}
    		// If the events is marked as instant, make it last 30 minutes
    		if( $instant_event ) {
    			$end_time = $start_time + 1800;
    		}
    
    		$event->start               = $ai1ec_events_helper->local_to_gmt( $start_time );
    		$event->end                 = $ai1ec_events_helper->local_to_gmt( $end_time );
    		$event->allday              = $all_day;
    		$event->instant_event       = $instant_event;
    		$event->venue               = $venue;
    		
    		$event->compilatore         = $compilatore;
    		
    		$event->address             = $address;
    		$event->city                = $city;
    		$event->province            = $province;
    		$event->postal_code         = $postal_code;
    		$event->country             = $country;
    		$event->show_map            = $google_map;
    		$event->cost                = $cost;
    		$event->is_free             = $is_free;
    		$event->ticket_url          = $ticket_url;
    		$event->contact_name        = $contact_name;
    		$event->contact_phone       = $contact_phone;
    		$event->contact_email       = $contact_email;
    		$event->contact_url         = $contact_url;
    		$event->recurrence_rules    = $rrule;
    		$event->exception_rules     = $exrule;
    		$event->exception_dates     = $exdate;
    		$event->show_coordinates    = $show_coordinates;
    		$event->longitude           = trim( $longitude ) !== '' ? (float) $longitude : NULL;
    		$event->latitude            = trim( $latitude ) !== '' ? (float) $latitude : NULL;
    
    		// if we are not saving a draft, give the event to the plugins. Also do not pass events that are imported from facebook
    		if( $post->post_status !== 'draft' && $event->facebook_status !== Ai1ecFacebookConnectorPlugin::FB_IMPORTED_EVENT ) {
    			$ai1ec_importer_plugin_helper->handle_post_event( $event, 'save' );
    		}
    		$saved_post_id = $event->save( ! $is_new );
    		if ( $post_twitter ) {
    			if ( ! add_post_meta(
    					$saved_post_id,
    					'_ai1ec_post_twitter',
    					'pending',
    					true
    			 ) ) {
    				update_post_meta(
    					$saved_post_id,
    					'_ai1ec_post_twitter',
    					'pending'
    				);
    			}
    		}
    
    		$ai1ec_events_helper->delete_event_cache( $post_id );
    		$ai1ec_events_helper->cache_event( $event );
    		// LABEL:magicquotes
    		// restore <code>magic</code> WordPress quotes to maintain compatibility
    		$_POST = add_magic_quotes( $_POST );
    		return $event;
    	}
    
  • Hi @Aminta

    Sorry, this is far beyond the free support service provided on this forum.

    Looks like you are doing some extreme customization which you will need to read the docs, and also the source code to find the solution.

    Thanks
    E

  • I know this is a really old thread but I’m trying something similar and was wonder if @aminta ever got this to work. I need to have a different block of code dropped in depending on the category of the event & am having a really tough time editing the .twig template for agenda view – all of my attempts at dropping in a conditional statement haven’t worked, but I also want to set it up so that the addition doesn’t get overwritten when the plugin is eventually updated.

    The solution I’m looking for definitely involves using ACF with the Time.ly calendar/Wordpress plugin…I just need some guidance.

    Any advice appreciated!

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

The topic ‘Integrate ACF in "All-in-one Event Calendar"’ is closed to new replies.