Created
May 3, 2020 15:50
-
-
Save renventura/77d2ead97f443c71c4e57cb7adbc128b to your computer and use it in GitHub Desktop.
Snippet for programmatically creating entries in WPForms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Create entry. | |
| $entry_id = wpforms()->entry->add( array( | |
| 'form_id' => absint( $form_id ), | |
| 'user_id' => absint( $user_id ), | |
| 'fields' => wp_json_encode( $fields ), | |
| 'ip_address' => sanitize_text_field( $user_ip ), | |
| 'user_agent' => sanitize_text_field( $user_agent ), | |
| 'date' => $date, | |
| 'user_uuid' => sanitize_text_field( $user_uuid ), | |
| ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the code works, BUT it only adds the entry to the database, it does not send confirmation mails, create pdf files, ... . on top of that the fields are not added to the table "wp_wpforms_entry_fields" (what happens, if you submit a form non programmatically). does anyone know how to trigger a "real" submit with php?