-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathfunctions-ur-form.php
66 lines (51 loc) · 1.47 KB
/
functions-ur-form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* UserRegistration Form Functions
*
* Functions related to forms.
*
* @package UserRegistration/Functions
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function ur_get_form_fields( $form_id ) {
$form_id = (int) $form_id;
$form_fields = array();
if ( ! empty( $form_id ) ) {
$post_content_array = ( $form_id ) ? UR()->form->get_form( $form_id, array( 'content_only' => true ) ) : array();
foreach ( $post_content_array as $row_index => $row ) {
foreach ( $row as $grid_index => $grid ) {
foreach ( $grid as $field_index => $field ) {
$field_name = $field->general_setting->field_name;
if ( $field_name ) {
$form_fields[ $field_name ] = $field;
}
}
}
}
}
return $form_fields;
}
function ur_get_form_field_keys( $form_id ) {
$form_fields = ur_get_form_fields( $form_id );
$field_keys = array();
if ( ! empty( $form_fields ) && is_array( $form_fields ) ) {
$field_keys = array_keys( $form_fields );
}
return $field_keys;
}
/**
* Returns settings for all form fields in proper array format.
*
* Uses UR_FrontEnd_Form_Handler::get_form_field_data() function.
*
* @param integer $form_id Form Id.
* @return array
*/
function ur_get_form_field_data( $form_id = 0 ) {
$post_content_array = ( $form_id ) ? UR()->form->get_form( $form_id, array( 'content_only' => true ) ) : array();
$form_field_data = UR_Frontend_Form_Handler::get_form_field_data( $post_content_array );
return $form_field_data;
}