Gravity Forms Registration – Add User to Multiple Sites
- Author: Tom Woodward
- Category: WordPress, Workflow
- Tags: gravityforms
You’ve got a scenario where someone is signing up to multisite via Gravity Forms’ user registration plugin. The following function will automatically add them to as many additional sites as you’d like.
add_action( 'gform_user_registered', 'many_site_registration_save', 10, 3 ); function many_site_registration_save( $user_id, $feed, $entry ) { $sites = array(25,26,27,28); //the IDs of the sites you want the user added to foreach ($sites as $site) { add_user_to_blog($site, $user_id, 'author'); //the last variable is the desired role for the user } }
Related posts
For Want of an API . . .
We wanted to be able to know whether people signing up for Ram Pages were faculty or not but didn’t want to add fields for them to fill out. VCU has an online phonebook with faculty emails in it but there didn’t appear to be a way to hook into an API. But you can provision the site with search items via the URL like so https://phonebook.vcu.edu/?Qname=woodwardtw%40vcu.edu. Since I knew that PHP can grab a website (file_get_contents) and parse out the text in various ways (preg_match) it seemed like we could automate this. When the phonebook site fails to find a matching email it returns some text that says ‘No matches.’ That’s what I decided to look for. If you look at the comments below, each line of the code is broken down and pretty much (over) explains what it does. Update Here’s a better version using curl and displaying the data in the user profile so you can see if you’re crazy or not. It also checks for the metadata field and updates or creates it as needed.
Auto Featured Image for Gravity Forms Posts by Response
This scenario is fairly specific, Gravity Forms to post and adding a specific featured image based on a form field but the ease of assigning a featured image via the media post ID is hand elsewhere and it’s always nice to document more ways to tweak Gravity Forms. Step One Upload your images to the WP Media Library. After uploading the images you want to use, go to the Media Library and change the view to list view. If you mouse over the edit button, you’ll see a URL appear in the bottom right of your browser window. Setup Your Form Take note of the entry ID of the form element that’s going to determine the featured image. It’s likely the same number you’d get if you counted the fields from top to bottom but if you made them and rearranged them it could be something else. If you mouse over the field in the form editor, you’ll see the form ID in blue. The Code Now we’re just writing a bit of PHP to tie into the form. In this case I’m tying it just to form 5 with this action add_action( ‘gform_after_submission_5’, ‘altlab_timeline_featured_image’, 10, 2 );. Leaving off the _5 would apply it to all forms and changing the 5 to another number would target another form. In […]
- Author: Tom Woodward
- Category: WordPress
- Tags: gravity forms, gravityforms
Monthly Reporting, A Gravity Forms to Google Forms Love Story
Well not really but I’ll explain it anyway. Gravity to Google There are a number of plugins that tie Gravity Forms to Google Sheets but most (all?) of them rely on the ability to create an application to get authentication tokens. Many institutional accounts turn off that capability. VCU has turned that off. As a result, I ended up going the more manual route with this Google Script integration. Note the Martin Hawksey mention! I won’t re-write their documentation here but it does work and it’s relatively easy to set up. Counting Unique Things Now that we had our data showing up, I wrote some stuff to summarize it. Nothing too fancy, but I do find myself using =sort(UNIQUE(Sheet1!E2:E)) which gets the unique values in column E and sorts them and then doing a =COUNTIF(Sheet1!E:E,”=”&A2) to count how many times those unique values show up. That all works pretty well for a summary look but there was also a desire for monthly data. That’s complicated by the data being added live on a continuous basis and the date field coming in with a full date/time stamp. I considered, and attempted, a variety of paths and ended up using =query. It works well and I thought some of the details were kind of neat. I also knew that I would forget […]
- Author: Tom Woodward
- Category: Data, Google, WordPress, Workflow
- Tags: google sheets, gravity forms
Comments on this post
Great to see how you fixed it!
/Jörg