Real life example of a function to create a Pods record from fields submitted on a form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php function add_new_applicant () { // Get field values from form submission $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $telephone = $_POST['telephone']; $email = $_POST['email']; $fields = array( 'first_name' => $first_name, 'last_name' => $last_name, 'telephone' => $telephone, 'email' => $email ); $new_id = pods( 'applicant' )->add( $fields ); return $new_id; } |
Could also have a run through pods_sanitize to make sure the data is safe to be added.
1 |
pods('applicant')->add ( pods_sanitize ( $fields ) ); |