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

Going Global: How To Use Global Divi Regions In The Divi Library

The Divi theme library is a powerful tool that can help you save time and streamline your website design process. One of the key features of the Divi library is the ability to create global rows. Global rows are essentially modules that you can reuse throughout your...

Making The Most of a Google Business Profile

Small business owners need to pay attention to their Google Business  profile. Given the power and reach of Google, having a business profile is like getting a desk somewhere at Google where you get to influence how people find your business. Some people don't even...

Customer Feedback and B2B: It’s Still Essential

How many times a day does the topic of online toxicity and cancel culture come up? That boils down to reputation management and how a comment can be an asymmetrical attack-- an attack with no adequate defense. Some business have spiralled and crashed thanks to a spate...

8 Things To Consider TO Build A Successful Ecommerce Website

The pandemic pushed businesses away from the traditional models and accelerated the move to online first interactions. Ecommerce has changed the face of commerce. Despite that,  most ecommerce websites will still fail. Things to keep in mind when building a highly...

What Is Data Resiliency?

Data resiliency is about having your organization's data always available and accessible even in the face of unexpected business disruptions such as cyber attacks. It allows a business to keep a handle on the data, continue to use the data and assess the potential for...

WordPress Trends for 2023

It is difficult to accurately predict specific trends in WordPress design for 2023, as the field is constantly evolving and new trends and technologies are emerging all the time. However, here are a few general predictions for WordPress that developers may want to...

Hiring a Webmaster vs. Retaining a Web Management Company

According to data from the Canada's Job Bank, the median hourly wage for web developers in Canada is $30.50. That works out to an annual salary of around $63,000 based on a full-time work week. It's important to consider other costs associated with hiring an employee:...

Porthole Solutions.com Acquired by Web321

We are proud to pick up the mantle of Porthole Solutions. Back in the day, they provided full service solutions. As they said it, back then: We provide full web services, including hosting and domain registration, and create custom designed websites that can be...

Indigenous Funding Options in BC

National Programs PacifiCan Jobs and Growth Fund  If you are working on a project for your business to transition to a green economy, foster an inclusive  recovery, become more competitive and create jobs for Canadians, you could get a contribution for up to 100% of...

Seven Ways To Set Up A Sponsored Website

Nonprofits that need a website have a dilemma: A website can be great for raising the profile of the organization, but a website built on a shoestring may fail to deliver its message nor get traction for the cause. 

Top 7 Signs A Website Is Abandoned

Websites need TLC. A garden and a website have a lot in common: They start in the dirt: for gardens, it’s literal soil; for websites, it’s dirt poor rankings and lack of discoverability.  The conditions need to be favourable to growth. Plant the seeds and give them...

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...