Linking Gravity Forms to BuddyPress Forums

by | Jan 31, 2023 | WordPress | 0 comments

I was posed with problem: make BuddyPress forum topics from a Gravity Forms form submission. Turning Gravity Form submissions into posts isn’t a big party trick– that is built in. What doesn’t work, is the linkage to a particular forum as a new topic. So: I did some hacking (see the code below).

  • I made a gravity form
  • I have it posting to the post_type for topics
  • I put in a hidden value with the label of “forum_id” and the number for that forum id as the default value for the hidden value
  • I had an existing plugin that was mine. I added the code below to listen for Gravity Form events and then act on the submission.
  • WordPress will do the submission, save the post, then go to this function to act and create linkage between the form submission and a forum.
// publish and associate the form

function sboxr_application_submission( $entry, $form ) {
	if (function_exists('bbp_update_forum')) {
	    //getting post
    	$post = get_post( $entry['post_id'] );

	    //changing post content
	    foreach ($form['fields'] as $key => $values) {
    		if ($values['label'] == 'forum_id') {
    			$post->post_parent = $values['defaultValue'];
    			break;
    		}   
	    }

		$forum_meta = array(
			'forum_id' => $post->post_parent,
			'topic_id' => $post->ID,		
			'comment_status' => 'open'
		);
		$post->comment_status = 'open';	
		$post->post_status = 'publish';

		bbp_update_forum(array('forum_id' => $post->post_parent));
	    //updating post
		wp_update_post($post);
	
		foreach ( $forum_meta as $meta_key => $meta_value ) {
			update_post_meta( $post->ID, '_bbp_' . $meta_key, $meta_value );
		}	
	}
}

// Hook to make the gravity form submission to connect to forum post creation
add_action( 'gform_after_submission_2', 'sboxr_application_submission', 10, 2 );

Threads: ActivityPub and WordPress

Meta has released a new microblogging app: Threads. It leverages the user base of Instagram and the users’ followers to pre-build an audience for new members. This may be an excellent antidote to the death spiral of Twitter. How does it work with WordPress?

Why We Like Combining Divi and ACF

I want to show you how we can use ACF and Toolset to insert dynamic content into our text editor. With ACF, we can easily find available fields and insert them into our content. We can also enable raw HTML to display content verbatim. Toolset works similarly, but it...

What Should You Consider Before A Website Re-Design

Let's dive into the essential considerations for undertaking a website redesign. There are both minor and major technical issues, ensuring mobile readiness, optimizing for search engines, and possibly migrating to a more reliable platform, such as WordPress....

Clearing Your Cache In WordPress

Caching is a storage of the presentation of data. Caching is vital to contain how much processing power is needed to run your site. It can also be a pain when a cache holds onto old information. When a user is looking at a database driven web page, there’s a high...

Building A Website For An Electrical Contractor

For an electrical contracting company, we help by creating a new website to replace an existing legacy infrastructure that is bound to hosing and support. WordPress frees up a website and to be hosted on the best platform available. Our designs are clean, responsive,...

How Would We Tackle a Pilates Website Rebuild

We're been asked several times about how we would re-design a pilates or fitness website. Here's a quick rundown of what we recommend. We propose the following features & functions: Move site hosting to WPPro.ca (managed, optimized WordPress hosting). Update the...

Web321 Won the 2023 ICCC-KFC Recipe For Success

We’re excited to share that we won the $30,000 CAD grant through the ICCC-KFC Recipe for Success Program! Thank you to Inner City Capital Connections and KFCCanada for the opportunity to participate in the ICCC program and receive this grant. We look forward to using it to help our business continue to grow!