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 );

An Old Dog With A Few Tricks: The Dogpile Search Engine

Dogpile, a name that might conjure up images of the last time you strolled through a busy park, has a rich history as a metasearch engine. Established in 1996 by Aaron Flin, a research attorney, Dogpile was born out of frustration with the search engines of the time....

Calligo Going Away And What You Can Do About Your Website

March 1st is coming up fast and Calligo (www.calligo.io) clients have to find somewhere for their sites to live. This from Calligo : Important notice about your website and mail service from Calligo (previously 3 Peaks / Pacific Online) From 1st March 2021, you will...

17 Ways To Win at Growth Hacking 

  Growth Hacking is a great option for anyone looking to grow their business fast! For anyone unfamiliar with the term, growth hacking refers to a series of techniques used to add social media followers rapidly and with minimum investment on your part. As growth...

Play Twenty Questions With Your Website Decisions

What is it that sets one site from another? In short, brand optimization: knowing what you want to present to your potential client and how you’re going to present it. To get there, and create the online performance your brand deserves, you need to consider some important questions.

Keeping Up With Google Algorithms

Google’s algorithm is known to have core changes every few months to improve the quality of search results – what does this mean for you and your website? With every change to the algorithm, if not detected immediately, can lead to severe impacts on your website...

Web Maintenance Checklist

If you own a site, whether it is for personal use as a blog or you use it for your business, the site must be maintained frequently. The system is constantly updated and if you do not take enough care of your site through proper web maintenance, you will not attract...

WordPress: How Popular Is It?

WordPress has become a global marvel and it has taken a long leap since its release in 2003. From the 1st version of WordPress in 2003, it has been growing considerably even today. Being the most superior CMS in this industry, WordPress stands above its rival brands...

Web Presence Grant from the NASE Growth Grant in 2020

Web Presence Assistance provides a non-repayable contribution to Prince Edward Island businesses to assist them in establishing a presence on the Internet. The purpose of this assistance is to help Island companies increase business by creating a website to establish...

Web Presence Assistance From Innovation Prince Edward Island

Web Presence Assistance provides a non-repayable contribution to Prince Edward Island businesses to assist them in establishing a presence on the Internet. The purpose of this assistance is to help Island companies increase business by creating a website to establish...