• Resolved enack

    (@enack)


    Hi I was just wondering,
    Is there any way to link this plugin to gravity forms somehow?
    I would love for users to add their opening hours when they register so that I can display it on a page

    Otherwise this is a fantastic plugin, the only thing I have been struggling with is the fact that I have to create the opening hours for EACH new user

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author janizde

    (@janizde)

    Hi enack,
    this is not directly implemented in the Plugin (and probably won’t be in future as in my opinion it’s out of scope of this project), but you can use the SetProvider API to implement this behavior on your own and then feed the Plugin with the raw Opening Hours data.

    More about the SetProvider API on GitHub:
    https://github.com/janizde/WP-Opening-Hours/blob/master/doc/set-providers.md

    Thread Starter enack

    (@enack)

    Hi Janizde thanks for getting back to me
    I was given a code that uses gravity form fields to add to a custom post, I was wondering if you can see any reasons why the hours fields are not being added (Im a newbie). Thanks

    //Create opening hours
    add_action(“gform_after_submission_11”, “create_new_set”, 10, 2);
    function create_new_set($entry, $form){
    //First need to create the post in its basic form
    $new_set = array(
    ‘post_title’ => ucwords($entry[15]),
    ‘post_status’ => ‘publish’,
    ‘post_author’ => 16, // this represents admin by default.
    ‘post_type’ => ‘op-set’,
    ‘timeStart’ => (entry[1]),//this will represent the form field that has a time field in it
    ‘timeEnd’ => (entry[2]),
    );
    $post_id = wp_insert_post($new_set);
    }

    Plugin Author janizde

    (@janizde)

    Hi enack, this will probably not work as wp_insert_post is not aware of timeStart and timeEnd.

    If you want to add custom Opening Hours by Gravity Forms results there are basically two ways:

    1. (recommended) Use your own data infrastructure (I believe Gravity Forms stores form submissions in their own DB tables) and use the SetProvider API, which I have linked to above, to “feed” the Opening Hours core with your data.

    2. Add an op-set post through wp_insert_post and then add Opening Hours through a Persistence object: https://github.com/janizde/WP-Opening-Hours/blob/master/classes/OpeningHours/Util/Persistence.php

    • This reply was modified 7 years, 11 months ago by janizde.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Gravity forms’ is closed to new replies.