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 in buddypress not working

  1. wollemi
    Member

    I am manually inserting a write blog form into a page in buddypress: "../members/lyradmil/write". My form displays fine but hitting the submit button does not submit the form. No entries are recorded. The page simply "refreshes" and nothing else happens. I have also included: <?php gravity_form_enqueue_scripts(1, true); ?> in the "header.php" file but to no avail.

    This is my code in "functions.php" to display the form:

    // Write blog
    		bp_core_new_nav_item(
    			array(
    				'name' => __( 'Write Blog', 'buddypress' ),
    				'slug' => 'write',
    				'position' => 50,
    				'show_for_displayed_user' => false,
    				'screen_function' => 'write_blog',
    				'item_css_id' => 'bp_special_nav',
    				'default_subnav_slug' => 'write'
    			)
    		);
    // Write blog (subnav)
    		bp_core_new_subnav_item(
    			array(
    				'name' => __( 'Write blog' ),
    				'slug' => 'write',
    				'parent_url' => $bp->loggedin_user->domain . $bp->slug,
    				'parent_slug' => 'write',
    				'screen_function' => 'write_blog',
    				'position' => 10,
    				'item_css_id' => 'bp_special_subnav'
    			)
    		);
    /* Create write blog page */
    		function write_blog() {
    			//add title and content here – last is to call the members plugin.php template
    			add_action( 'bp_template_title', 'write_blog_title' );
    			add_action( 'bp_template_content', 'write_blog_content' );
    			bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    		}
    
    		/* Link title for Write blog page */
    		function write_blog_title() {
    			echo 'Start writing!';
    		}
    
    		/* Add content to the Invite page */
    		function write_blog_content() {
    			//add_filter( 'bp_get_activity_content_body', 'do_shortcode' );
    			echo do_shortcode('[gravityform id=1 title=false description=false ajax=true]');
    			//gravity_form(1, false, false, false, '', true);
    		}
    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  2. Can you try it without AJAX and see if it submits then?

    Can you share a link to your form page, if we will be able to submit it?

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  3. wollemi
    Member

    I tried it without AJAX as well but it still does not submit. The project is still in development and is not yet online.

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  4. OK. When you have it online, we will be happy to take a look at it for you. With AJAX turned on, it might have been a JavaScript conflict. But with AJAX turned off, that should not be the case, and there is something else going on.

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  5. wollemi
    Member

    It won't be able to come online if I can't fix this though. Is there a workaround? I just need it to show up inside a buddypress page template (with the headers, avatars, etc.).

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  6. wollemi
    Member

    Perhaps you could replicate my code on your machine and see what happens. All I did was to create a simple blog post form (with title and body), and tried embedding it in buddypress as described in my first post.

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  7. wollemi
    Member

    When I tried this:

    echo do_shortcode('[gravityform id="1" name="Write Blog" title="false" description="false" ajax="false"]');

    instead of:

    gravity_form(1, false, false, false, '', false);

    .. the same thing happens.

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  8. wollemi
    Member

    Ok it works now! Here's the solution (plug it into "functions.php"):

    function bbg_switch_gf_hooks() {
        remove_action('wp',  array('RGForms', 'maybe_process_form'), 9);
        add_action( 'bp_actions', array( 'RGForms', 'maybe_process_form' ), 1 );
    }
    add_action( 'init', 'bbg_switch_gf_hooks', 99 );

    .. for more details: http://www.gravityhelp.com/forums/topic/form-submission-buddypress

    Posted 10 years ago on Thursday January 12, 2012 | Permalink
  9. sascha
    Member

    Hi wollemi,

    thanks for posting your code right at the top! That will help me set up some extra navigation items. Just did not seem to work last time I tried and the BP skeleton component is a bit overkill I thought. Would you know why the hooks needs to be switched? Does that have any negativ effects further down the line?

    Is the wp hook totally redundant?

    Posted 10 years ago on Sunday January 15, 2012 | Permalink
  10. Fantastic find for this tricky problem. If you're using it as a plugin / class, the following call will also ensure that the modification only fires when buddyPress is active:

    if(function_exists('bp_core_get_userid')) {
    	add_action( "init", array(&$this, "bbg_switch_gf_hooks"), 99 );
    }
    Posted 9 years ago on Saturday March 3, 2012 | Permalink