| @@ -420,5 +420,35 @@ | ||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | return $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}weforms_payments WHERE entry_id = {$this->id} " ); |
| 423 | 423 | } |
| 424 | + | |
| 425 | + /** | |
| 426 | + * Get Form from entry id. | |
| 427 | + * | |
| 428 | + * @param int $entry_id The entry id. | |
| 429 | + * @global object $wpdb The Wordpress database object. | |
| 430 | + * | |
| 431 | + * @return object The form object. | |
| 432 | + */ | |
| 433 | + public static function get_form( $entry_id ) { | |
| 434 | + $form_id = self::get_form_id( $entry_id ); | |
| 435 | + | |
| 436 | + return ! empty( $form_id ) ? weforms()->form->get( $form_id ) : null; | |
| 437 | + } | |
| 438 | + | |
| 439 | + /** | |
| 440 | + * Get form id from entry id. | |
| 441 | + * | |
| 442 | + * @param int $entry_id The entry id. | |
| 443 | + * @global object $wpdb The Wordpress database object. | |
| 444 | + * | |
| 445 | + * @return int The form id. | |
| 446 | + */ | |
| 447 | + public static function get_form_id( $entry_id ) { | |
| 448 | + global $wpdb; | |
| 449 | + | |
| 450 | + $results = $wpdb->get_results( "SELECT form_id FROM {$wpdb->prefix}weforms_entries WHERE id = {$entry_id} " ); | |
| 451 | + | |
| 452 | + return ! empty( $results[0]->form_id ) ? $results[0]->form_id : null; | |
| 453 | + } | |
| 424 | 454 | } |