Events+ and Gravity Forms / Front-End Posting with additional fields / Buddypress

I am aware that Events+ comes with front-end posting/editing capabilities. However, since I require additional taxonomies to go together with an event posting, I would like to use Gravity Forms for front-end submission.

I kind of got it working with all my taxonomies etc, also hiding stuff from the user using a "hidden" custom post field.

However, one problem remains:
After submission, everything is created properly, except for the Buddypress Activity entry link ("user has created a new event"), which, instead of linking to site/year of event/month of event/title links to site/year of creation/month of creation/title. So if an event takes place in June but is created today, it links to site/2013/4/title instead of site/2013/6/title. The event link itself (in archives, etc) is correct, only the link Buddypress Activity stream contains the wrong link...

Any ideas how to:
- fix this
- purge the /year/month/ from the link completely and replace it by a custom permalink structure, eg /site/event/by/user/title, which would be what I prefer...

  • Hannes Heckel

    I figured it out myself - although I still have no idea why the wrong link is created.

    Step 1 - Turn off automatic buddypress activity posting (if you want automatic bp activity posting for attendance, you might leave the addon installed and just disable the notification upon creation - there is a bug that prevents you from setting the "No activity update" action, I used "Group only".

    Step 2 - Create your Gravity Form and submit all the custom fields except for the dates and times for GF won't let you check against valid dates (end before start etc). I also left out group and status, although both are mandatory entries in the database. Status: I included a logic where events are automatically expired when the date is in the past. Group: I am trying to find a way to auto-create a group upon event creation for discussion and images.

    Step 3 - Put something in your functions.php:

    add_action("gform_after_submission_8", "validate_activity", 10, 2);
    function validate_activity($entry, $form){
        //getting post
        $id = $entry["post_id"];
        $event = get_post($id);
        $meta = get_post_meta($id);
        //date and time stuff
        $start = $meta['incsub_event_no_start'] == 1
        	? $entry[17]
        	: $entry[17] . ' ' . $entry[16];
        update_post_meta($id, 'incsub_event_start', $start);	
        $end = $entry[20] == ''
        	? $start
        	: $entry[20];
        $end = $meta['incsub_event_no_end'] == 1
        	? $end
        	: $end . ' ' . $entry[22];
        $end = strtotime($end) < strtotime($start)
        	? $start
        	: $end;
        update_post_meta($id, 'incsub_event_end', $end);	
        //setting the status
        $status = strtotime($end) < strtotime('now')
        	? 'expired'
        	: 'open';
        update_post_meta($id, 'incsub_event_status', $status);	
        $group = 0;
        update_post_meta($id, 'eab_event-bp-group_event', $group);	
        //set creator as attending
        update_post_meta($id, 'incsub_event_yes_count', 1);
        update_post_meta($id, 'incsub_event_attending_count', 1);
    		global $wpdb, $current_user;
    	    $event_id = $id;
    	    $user_id = get_current_user_id();
    		    $wpdb->prepare("INSERT INTO wp_eab_bookings VALUES(null, %d, %d, NOW(), 'yes') ON DUPLICATE KEY UPDATE <code>status</code> = 'yes';", $event_id, $user_id)
    	// Buddypress
    	$user_link = bp_core_get_userlink($event->post_author);
    	$update = false;
    	$update = sprintf(__('%s hat eine neue Aktivität angelegt', Eab_EventsHub::TEXT_DOMAIN), $user_link);
    	$update = sprintf("{$update}: <a href='%s'>%s</a>", get_permalink($event->ID), $event->post_title);
    	$activity = array(
    		'action' => $update,
    		'component' => 'eab_events',
    		'type' => 'event_created',
    		'item_id' => $event_id,

    - The function is added to the GF with ID 8 - replace with your ID
    - It pulls the post and post meta
    - It validates the time, so that the user can leave end date empty etc. ´$entry[##]` are the GF field IDs.
    - It sets the status
    - It sets no group - here my group creation will kick in later
    - It sets the creator as first attendant - I have no idea why this is missing in the original code
    - Finally, it updates Buddypress correctly. Although this is almost exactly the function from the addon, this time the link created is correct.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.