PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Form submission & Buddypress

  1. fozzybear
    Member

    I am working to help someone get a gravity form working as means to frontend post submission.

    The requirements are that the form needs to run on a BuddyPress group page also it needs to tie in to a group category plugin (secondary requirement)

    The form itself works fine run as a shortcode on standard WP page.

    To enable the shortcode to work on the BP group page I had use do_shortcode('[gravityform]')

    That worked fine however the form wont submit at all, page doesn't refresh nor form details clear. I tried setting ajax to false and also disabled JS in my browser to no avail.

    Is there some trick to getting things working? In using the do_shortcode have I caused an issue, do I need to do anything further?

    Or is it simply a case that we can't run the form through a BP component in this manner?

    the secondary requirement runs a form through the plugin function but that isn't so important as simply getting form submission working.

    We're running with WP 3.2.1 / BP 1.5 / GF 1.5.3

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  2. fozzybear
    Member

    I have changed to embedding a function directly to the group screen page with basic functionality.
    Updated GF to 1.6 RC

    But these changes still produce no form submission.

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  3. Hi Fozzybear,

    Is it possible to share a link to the page in question so I can get a better idea of your issue?

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  4. fozzybear
    Member

    Certainly: it's under a coming soon wrapper at the moment but I can disable that for a while.

    Link is:
    http://sporthaq.com/groups/all-saints-school/blog/create

    In that create page I have simply dropped
    <?php gravity_form(4, true, true, false, '', false); ?>

    For testing, the plugin that links blogs to categories in the groups runs a function to enable front end posting hence it's create page and needs the function set:

    add_action('bcg_post_form', 'rh_student_form',10,2);
    function rh_student_form($cats,$url){
    //$cats is arra of category ids associated with this group
    //url is the url of current page
    //echo do_shortcode('[gravityform id=4 name=wppost title=false description=false ajax=false]');
    //gravity_form(4, true, true, false, '', false);
    }
    ?>

    But this aspect I'm not tackling until I can get basic submission working.

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  5. Hi Fozzybear, looks like I need to be a registered user to access that page?

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  6. fozzybear
    Member

    Sorry my bad,

    have to give you an admin account as the group blog plugin appears to be restricting the create page or roles are set up badly.

    [redacted]

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  7. Hi Fozzybear,

    Try adding this to your theme's functions.php: http://pastie.org/2767118

    Let me know if it works.

    Posted 13 years ago on Thursday October 27, 2011 | Permalink
  8. fozzybear
    Member

    That's great yes it does allow the form submission to pass through from that page correctly, many thanks for that. The page slightly oddly refreshes back to the members top level directory which I'll have to look into.

    I'm going to try and push the form through the plugin function I showed above, although I'm not expecting huge success there partly as there isn't any real documentation as to how that part of the plugin is functioning.

    The only real reason I can see for the function is to pass through the array of categories selected in that respect I only really need to pass through one category which needs to ID the group that I can do simply by accessing the group object and getting the group slug and using that as the post category if necessary rather than an array of selected categories, but how do I pass a category through to the GF form prior to submission? I'm guessing I need to do this via the form settings page by allowing Allow field to be populated dynamically and adding a variable - does GF then simply collect any data from a variable if I create it on the page?

    Posted 13 years ago on Thursday October 27, 2011 | Permalink
  9. fozzybear
    Member

    And I can pass the form via the function I showed above although the page is just hanging on submission and I have to refresh and halt the page but the form has passed through to drafts though.

    What I can't see is how the form collects a category, I've set 'allow field to be pop dynamically' and set a variable but not sure how the form function grabs that variable other than must need a parameter to be passed along so will have a quick read of docs.

    Posted 13 years ago on Thursday October 27, 2011 | Permalink
  10. Hi Fozzybear,

    I'm assuming the $group object might be global. If so, you can likely declare the global from within the gform_field_value hook and populate the field that way. Here is more information on dynamic population via hooks:

    http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population#Hooks

    Posted 13 years ago on Thursday October 27, 2011 | Permalink
  11. fozzybear
    Member

    Thanks David, unfortunately I did read the docs on hooks before and again as you linked to above but I'm not able to pass through even a simple string via a filter, but then I don't really find anything intuitive or easy about WP filters and hooks, theory is great, using is intimidating :)

    Posted 13 years ago on Saturday October 29, 2011 | Permalink
  12. fozzybear
    Member

    I apologise for bringing this back up but I'm getting stumped on trying to pass a value to the form despite trying a few variations,

    Currently this is the working form:
    primary page runs this function:
    bcg_get_post_form(bp_get_group_id());

    it grabs the function in functions.php:

    function rh_student_form($cats,$url){
    
    global $group_slug;
    echo $group_slug; // this variable is valid
    
    //$cats is arra of category ids associated with this group
    //url is the url of current page
    
    gravity_form(4, true, true, false, '', false);
    }

    In this sense the form works fine -ish it's displayed and will submit albeit re-freshing back to the members directory but this I think is an issue with the complicated way BP creates urls and root components.

    What I can't work out is how to pass $group_slug to the GF form category field to pre-populate it or simply populate it as group_slug is dependent on the group id being viewed at that time so isn't fixed. I tried the suggestion earlier and have set the form to take a parameter tried as '$group_slug' & 'group_slug'

    The snippet I'm working with is:

    add_filter("gform_field_value_category", "add_field_value");
    function add_field_value($group_slug){
    
        return $group_slug;
    }

    This I have tried in functions.php and actually within the function above 'rh_student_form'

    But no joy. I realise that what I have doesn't remotely feel like it ought to work but even checking a few other posts where you mention 'create_function'? in the add_action I'm failing to see how to accomplish this or really what to try next.

    Help / further guidance would be greatly appreciated.

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  13. David is out today, but I will forward this to him so he can assist you with it.

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  14. fozzybear
    Member

    Thanks Carl, appreciate it.

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  15. Hi Fozzybear,

    Assuming that the $group_slug is indeed a global variable (per your example above), you could populate a field with it's value like so:

    [php]
    add_filter("gform_field_value_category", "add_field_value");
    function add_field_value($value){
        global $group_slug;
        return $group_slug;
    }

    This assumes that there is a field on the form with the dynamic population parameter set to "category".

    Posted 13 years ago on Tuesday November 1, 2011 | Permalink
  16. fozzybear
    Member

    Ah I had tried the above but I hadn't set the form dynamic parameter to 'category' I had assumed that this would be 'group_slug' so I will give that a try the only other thing that does confuse me is where this function should run inside of the other plugins function that holds the GF form or outside that function both positions being in functions.php but I guess that's one of those trial and error questions :)

    Thanks for the help, I shall report back on success or fail.

    Posted 13 years ago on Tuesday November 1, 2011 | Permalink
  17. fozzybear
    Member

    Well sadly I have tried every way I can think of , changed the form parameter to 'category' moved the add_action around, tried taking the form out of the other plugins function, even tried a simple string to return matching to an existing post category to rule out any issues with the variable even though it's good, but each post that gets aded as a draft is always of category 'uncategorized'

    So completely stumped now :)

    Posted 13 years ago on Tuesday November 1, 2011 | Permalink
  18. fozzybear
    Member

    I have now created a test page and embedded the form on this (did this originally but not with later changes) to remove the BP aspect altogether.

    I can see that the value is being passed to the field that I have set as a simple string but I don't see how the form control as any relationship to a WP post category or how the form action is being constructed this simple page name / slug is returning the user to the BP members directory instead of simply doing a '/'

    <form id="gform_4" action="/test-gf-post-page/" enctype="multipart/form-data" method="post">
    <div class="gform_heading">
    <div class="gform_body">
    <ul id="gform_fields_4" class="gform_fields top_label description_below">
    <li id="field_4_1" class="gfield">
    <li id="field_4_2" class="gfield">
    <li id="field_4_5" class="gfield">
    <label class="gfield_label" for="input_4_5">Post Tags</label>
    <div class="ginput_container">
    </li>
    <li id="field_4_6" class="gfield field_admin_only">
    <input id="input_4_6" class="gform_hidden" type="hidden" value="All Saints School" name="input_6">
    </li>
    </ul>
    </div>
    <div class="gform_footer top_label">

    I set the 'Post Category' to admin only for this test but either way I appear to get same results?

    Posted 13 years ago on Tuesday November 1, 2011 | Permalink
  19. fozzybear
    Member

    Apologies for a shameless bump

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  20. Hi Fozzybear,

    So the category ID is populating the field specified correctly; however, the created post is not automatically assigned that category?

    Posted 13 years ago on Monday November 28, 2011 | Permalink

This topic has been resolved and has been closed to new replies.