PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/fields/FrmFieldUserID.php +12 -33 6.265.0 View file →
@@ -9,9 +9,8 @@
9 9 class FrmFieldUserID extends FrmFieldType {
10 10
11 11 /**
12 12 * @var string
13 - *
14 13 * @since 3.0
15 14 */
16 15 protected $type = 'user_id';
17 16
@@ -16,9 +15,8 @@
16 15 protected $type = 'user_id';
17 16
18 17 /**
19 18 * @var bool
20 - *
21 19 * @since 3.0
22 20 */
23 21 protected $has_input = false;
24 22
@@ -23,9 +21,8 @@
23 21 protected $has_input = false;
24 22
25 23 /**
26 24 * @var bool
27 - *
28 25 * @since 3.0
29 26 */
30 27 protected $has_html = false;
31 28
@@ -30,19 +27,13 @@
30 27 protected $has_html = false;
31 28
32 29 /**
33 30 * @var bool
34 - *
35 31 * @since 3.0
36 32 */
37 33 protected $holds_email_values = true;
38 34
39 35 /**
40 - * @var bool
41 - */
42 - protected $array_allowed = false;
43 -
44 - /**
45 36 * @return string
46 37 */
47 38 protected function include_form_builder_file() {
48 39 return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/field-user-id.php';
@@ -56,20 +47,16 @@
56 47 }
57 48
58 49 /**
59 50 * @since 4.03.06
60 - *
61 - * @param array $args Field display arguments.
62 - *
63 - * @return int|string
64 51 */
65 52 protected function get_field_value( $args ) {
66 53 $user_ID = get_current_user_id();
67 54 $user_ID = ( $user_ID ? $user_ID : '' );
68 - $posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
69 - $action = ( $args['action'] ?? $args['form_action'] ?? '' );
70 - $updating = $action === 'update';
71 - return is_numeric( $this->field['value'] ) || $posted_value || $updating ? $this->field['value'] : $user_ID;
55 + $posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); // WPCS: CSRF ok.
56 + $action = ( isset( $args['action'] ) ? $args['action'] : ( isset( $args['form_action'] ) ? $args['form_action'] : '' ) );
57 + $updating = $action == 'update';
58 + return ( is_numeric( $this->field['value'] ) || $posted_value || $updating ) ? $this->field['value'] : $user_ID;
72 59 }
73 60
74 61 public function validate( $args ) {
75 62 if ( '' == $args['value'] ) {
@@ -75,15 +62,15 @@
75 62 if ( '' == $args['value'] ) {
76 63 return array();
77 64 }
78 65
79 - // Make sure we have a user ID.
66 + // make sure we have a user ID
80 67 if ( ! is_numeric( $args['value'] ) ) {
81 68 $args['value'] = FrmAppHelper::get_user_id_param( $args['value'] );
82 69 FrmEntriesHelper::set_posted_value( $this->field, $args['value'], $args );
83 70 }
84 71
85 - // Add user id to post variables to be saved with entry.
72 + //add user id to post variables to be saved with entry
86 73 $_POST['frm_user_id'] = $args['value'];
87 74
88 75 return array();
89 76 }
@@ -88,12 +75,12 @@
88 75 return array();
89 76 }
90 77
91 78 /**
92 - * @param array|string $value
93 - * @param array $atts
79 + * @param $value
80 + * @param $atts array
94 81 *
95 - * @return array|string A string is returned, but the return signature should match FrmFieldType.
82 + * @return false|mixed|string
96 83 */
97 84 protected function prepare_display_value( $value, $atts ) {
98 85 $user_info = $this->prepare_user_info_attribute( $atts );
99 86
@@ -106,9 +93,9 @@
106 93 * From the get_display_name() function
107 94 *
108 95 * @since 3.0
109 96 *
110 - * @param array $atts
97 + * @param $atts
111 98 *
112 99 * @return string
113 100 */
114 101 private function prepare_user_info_attribute( $atts ) {
@@ -125,10 +112,10 @@
125 112 return $user_info;
126 113 }
127 114
128 115 /**
129 - * @param string $value
130 - * @param array $atts
116 + * @param $value
117 + * @param $atts
131 118 *
132 119 * @return int
133 120 */
134 121 protected function prepare_import_value( $value, $atts ) {
@@ -136,17 +123,9 @@
136 123 }
137 124
138 125 /**
139 126 * @since 4.0.04
140 - *
141 - * @param mixed $value Field value passed by reference.
142 - *
143 - * @return void
144 127 */
145 128 public function sanitize_value( &$value ) {
146 - if ( '' === $value ) {
147 - // Allow for an empty User ID. Return early to prevent it from getting set to 0.
148 - return;
149 - }
150 129 FrmAppHelper::sanitize_value( 'intval', $value );
151 130 }
152 131 }