Organizer and Venue custom post types : mapping Title from frontend form

Home Forums Calendar Products Events Calendar PRO Organizer and Venue custom post types : mapping Title from frontend form

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #87336
    Marcus J Wilson
    Participant

    Hi –
    We’re using ECP in a Film Festivals project. We’re using Community Events for users to submit events in the front end, but we’d like to use Gravity Forms (+Custom Post Types) to allow users to submit Venues and Organizers to ECP, with additional fields we’ve built on to the tribe_venue and tribe_organizer post types.

    It’s all working great, with fields mapping as expected, apart from the Venue and Organizer Title which just come into ECP as “Unnamed Venue” or “Unnamed Organizer”.

    Is there something about the way that titles are set up in the ECP Venue and Organizer custom post types that may be causing these titles not to map from the front end? We’ve tested adding events to tribe_events custom post type with Gravity Forms, and the Titles are coming over fine for this custom post type.

    Any advice appreciated!

    Best
    Marcus

    #88001
    Brook
    Participant

    Howdy Marcus,

    Without being able to view the specific form where you are submitting data from we will not be of much help. We might even need to see the backend form settings.

    From a general standpoint the main thing that separates those two from the rest of the form is that they would have to be select/option HTML elements. With <option>s the displayed title is not the submitted value. For instance my venue titled “K place” has a value of “50”. You would want Gravity forms to be submitting the value of 50, not the title “K place” to select that particular venue. Does that make sense?

    Please let me know if that helps you resolve the issue. Thanks!

    – Brook

    #88323
    Marcus J Wilson
    Participant

    Thanks, Barry – That helps us with regard to a front end Events submission form.

    However, I think you misunderstand my question. We’re actually building a front end form to submit Organizers to the Custom Post Type tribe_organizer, independent of any event submission.

    We are finding that, using Gravity forms, we can create a tribe_organizer custom post, populate all its fields (as well as some additional fields we’ve added). However, we can’t get the front end form to populate the tribe_organizer post Title… The post shows up in Events Calendar Pro’s Organizer’s post list as “Unnamed Organizer”.

    We’re tried populating both the custom post Title and the field _OrganizerOrganizer (which Barry tells us is a duplicate of the post title). However, we’re still seeing the post come in to Events Calendar Pro as “Unnamed Organizer”.

    We see the same issue when we try to populate tribe_venue custom post type from a front end form.

    My question therefore is: Is there something special about the way ECP creates these Venues and Organizers custom post types that is preventing us from populating their Titles correctly from a front end form, or is there some function called when posts are created for these custom post types that mean that our Title value gets lost along the way.

    We have a really simple test form at http://takeoneaction.org.uk.dev.pooka.info/add-org-title-field/ that we are using to test population of the Title and _OrganizerOrganizer fields, and we can give you access to the website admin if you like.

    Many thanks!
    Marcus

    #88430
    Brook
    Participant

    I follow you now. Thanks for clarifying. Please pardon the confusion.

    We do have some public functions to assist with this:

    http://docs.tri.be/Events-Calendar/function-tribe_create_organizer.html

    http://docs.tri.be/Events-Calendar/function-tribe_create_venue.html

    I am not sure how much that will help you though. While it has been a while since I have worked with Gravity forms, I do not recall any method for allowing a function to process your data.

    As far as the actual logic behind it, it is all quite basic. You can find the relevant bits of PHP here:

    http://docs.tri.be/Events-Calendar/source-class-TribeEventsAPI.html#293-320

    http://docs.tri.be/Events-Calendar/source-class-TribeEventsAPI.html#215-241

    Essentially it is just parsing your data into a simple array and passing that to wp_insert_post().

    Does that help? Did I understand you correct this time?

    – Brook

    #88452
    Marcus J Wilson
    Participant

    Ah yes – Thanks, Brook – this looks like we’re getting close now.

    So… at the moment, we’re using the “Gravity Forms + Custom Post Types” functionality to create a new tribe_organizer post from the front end in the usual way.

    However, it seems like ECP is then hijacking the submitted post and running its createOrganizer function on the data, which replaces our Title from the Gravity form with “Unnamed Organizer”… probably because it is expecting the Title data in a different format than how Gravity Forms is presenting it.

    http://docs.tri.be/Events-Calendar/source-class-TribeEventsAPI.html#226

    Does that sound likely? If so, I guess we may need to tweak the createOrganizer function, or to stop it running on our Gravity Form submission? Does that sound about right? If so, where does createOrganizer get hooked in to the post creation process?

    Thanks for your help!
    Marcus

    #88473
    Brook
    Participant

    That seems hyopothetical, but not likely to me. The line you linked should set it to Unnamed only if the key ‘Organizer’ is blank or not set. Are you 100% positive that you are setting this case-sensitive key? In order to even reach that point, you would have to be setting at least one of the other keys correctly. They are all found on line 16. So you probably are setting it right, but I figure it is worth double checking.

    I would recommend against tweaking the function if you go that route. If Gravity forms lets you submit to an arbitrary location, why not roll your own simple submission script? You could copy and paste the relevant bits of logic from that function and remove anything you do not need. Then point Gravity forms to it via _GET or _POST (whichever you prefer). Would that work for ya?

    – Brook

    #90899
    Marcus J Wilson
    Participant

    For info… to resolve the issue of submitting Organizer (or Venue) titles from a Gravity Form (+Custom Post Types) into Events Calendar Pro, we ended up adding a hook to our site’s functions.php. This hooks takes the value of the Organizer (as it is submitted in the field from Gravity Forms) and change it into the value expected by Events Calendar Pro:

    add_action( ‘save_post’, ‘dx_prepare_organization’, 15 );
    function dx_prepare_organization() {
    if( ! empty( $_POST[‘gform_submit’] ) && $_POST[‘gform_submit’] == ‘8’ ) {
    $_POST[‘organizer’][‘Organizer’] = $_POST[‘input_1’];
    }
    }

    This hook fires immediately before ECP’s own hook, so it prepares the data before it is passed to ECP.

    $_POST[‘gform_submit’] == ‘8’ should be set to your Gravity Form ID.
    $_POST[‘input_1’] should be set to the name of the field in the Gravity Forms that is used to record the Organizer title.

    I hope this helps others!

    Many thanks for your help with this, Brook.

    Best
    Marcus

    #90982
    Brook
    Participant

    Much appreciated Marcus! This will be an enormous help to other who want to do the same thing. Thanks!

    – Brook

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Organizer and Venue custom post types : mapping Title from frontend form’ is closed to new replies.