Title: Automatically create related items
Last modified: August 22, 2016

---

# Automatically create related items

 *  Resolved [johnaq](https://wordpress.org/support/users/johnaq/)
 * (@johnaq)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/automatically-create-related-items/)
 * I’m very new to Pods and have searched this forum and pods.io for help. I’m just
   using Pods in WP, no php.
 * I have set up 2 pods ‘Events’ and ‘Registrations’. They are related – events 
   can have may child registrations. A registration has only one parent event.
 * Using a basic template and shortcode, I can create and view an event page, and
   put a registration form on that page so someone could register from the front
   end. However, from what I can tell, the registration form still requires the 
   user to select the related event.
 * How can the new registration automatically relate to the event being viewed?
 * Have tried to understand relationships and default values, but just can’t quite
   put it together.
 * Thanks in advance
 * [https://wordpress.org/plugins/pods/](https://wordpress.org/plugins/pods/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Contributor [Jim True](https://wordpress.org/support/users/jimtrue/)
 * (@jimtrue)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402091)
 * If you have the registration form on the same page with the individual event,
   you can create a ‘hidden’ field in the form that is set to the related event 
   so that the user doesn’t have to or get to select it.
 * How are you creating the Registration Form? Using the form() function from PODS
   or a shortcode?
 *  Thread Starter [johnaq](https://wordpress.org/support/users/johnaq/)
 * (@johnaq)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402093)
 * Thanks for the reply Jim.
 * I’m using a shortcode to create the form. It’s a very bare bones set up at the
   moment.
 * I guess my question is how do “create a ‘hidden’ field in the form that is set
   to the related event”? Is that by setting a default value? What would the magic
   code be for that?
 *  Thread Starter [johnaq](https://wordpress.org/support/users/johnaq/)
 * (@johnaq)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402194)
 * I’m slowly pulling together an understanding of what magic tags work (and – just
   as importantly – where) really wish I could find a definitive list/reference.
 * So it seems like if I could set the default value of my the ‘event’ field in 
   the relationships pod to {@ID} then I’d be good to go but this doesn’t seem to
   work from within the shortcode Registration form on an Event page.
 * BTW, I really have no idea what Set Default Value by Parameter does
 * I hope that all makes sense
 *  Plugin Contributor [Josh Pollock](https://wordpress.org/support/users/shelob9/)
 * (@shelob9)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402204)
 * There is no way to do a hidden form in a shortcode. Instead use `Pods::form()`
 * [http://pods.io/docs/code/pods/form/](http://pods.io/docs/code/pods/form/)
 *  Thread Starter [johnaq](https://wordpress.org/support/users/johnaq/)
 * (@johnaq)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402210)
 * Is there now way to achieve this using ‘Set Default Value’. It seems like a lot
   of trial and error to figure out what works.
 * Where can one learn about ‘via Paramater’
 *  Plugin Contributor [Jim True](https://wordpress.org/support/users/jimtrue/)
 * (@jimtrue)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402221)
 * If you’re not terribly comfortable with PHP, you can do exactly what you’re looking
   for with the Gravity Forms Plugin for Pods:
 * [https://github.com/pods-framework/pods-gravity-forms](https://github.com/pods-framework/pods-gravity-forms)
 * Sorry to keep pointing you to different options, but looking at your questions,
   you don’t seem that comfortable with PHP and the shortcode for forms is VERY 
   rudimentary, there are a large handful of things you can send to that shortcode,
   though. This article breaks down what’s available:
 * [http://pods.io/docs/learn/shortcodes/pods/](http://pods.io/docs/learn/shortcodes/pods/)
 * it allows you to specify a Pods Template to use, so reasonably, you COULD create
   a very specific HTML form using a Pods Template and magic tags to include just
   the fields you want and set the individual event value on the form.
 * We don’t really have a way to set a default value for the form, because the form
   doesn’t know the context of where it is, especially if you’re creating one that
   is based off another Event. Gravity Forms definitely makes this a little easier.
 *  Thread Starter [johnaq](https://wordpress.org/support/users/johnaq/)
 * (@johnaq)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402225)
 * Hi Jim
 * No need to apologise, thanks for time and help!
 * You’re right, I’m no PHP expert, so was keen to explore all options through Pods
   itself.
 * My first impression was that I could achieve what I was after (automatically 
   creating a related registration from an event page) by being able to set the 
   default value of the related registration field and hiding it from the UI using
   Pods Admin. I’m still not sure why this doesn’t work, and what ‘set via parameter’
   does.
 * Anyway, I have managed to achieve what I wanted in a Pods template using Pods::
   form() as follows…
 *     ```
       $regPod = pods( 'registration' );
       $thisEventID = $obj->id();
       $formFields=array('email', 'event' => array( 'default' => $thisEventID, 'type' => 'hidden' ));
       echo $regPod->form($formFields);
       ```
   
 * I hope that all makes sense
 *  Plugin Contributor [Jim True](https://wordpress.org/support/users/jimtrue/)
 * (@jimtrue)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402235)
 * Actually that makes perfect sense and is probably the best way to get the form
   to work the way you’d like without going the Gravity Forms direction.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Automatically create related items’ is closed to new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

 * 8 replies
 * 3 participants
 * Last reply from: [Jim True](https://wordpress.org/support/users/jimtrue/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/automatically-create-related-items/#post-5402235)
 * Status: resolved