Skip to content

Commit 73662c3

Browse files
authored
Merge pull request #242 from WPUserManager/#232
Added user role conditional for custom fields
2 parents be5e8f6 + 75b22ef commit 73662c3

18 files changed

+246
-45
lines changed

dist/static/css/fields-editor.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/css/fields-editor.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/css/registration-forms-editor.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/css/registration-forms-editor.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/fields-editor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/fields-editor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/manifest.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/registration-forms-editor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/registration-forms-editor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/abstracts/abstract-wpum-field-type.php

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -146,75 +146,75 @@ public function get_data_keys() {
146146
protected function get_default_editor_settings() {
147147

148148
$settings = [
149-
'general' => [
150-
'field_title' => array(
149+
'general' => [
150+
'field_title' => array(
151151
'type' => 'input',
152152
'inputType' => 'text',
153153
'label' => esc_html__( 'Field title', 'wp-user-manager' ),
154154
'model' => 'field_title',
155155
'required' => true,
156156
'placeholder' => esc_html__( 'Enter a title for this field', 'wp-user-manager' ),
157157
'validator' => [ 'string' ],
158-
'min' => 1
158+
'min' => 1,
159159
),
160160
'field_description' => array(
161161
'type' => 'textArea',
162162
'inputType' => 'text',
163163
'label' => esc_html__( 'Field description (optional)', 'wp-user-manager' ),
164164
'model' => 'field_description',
165165
'rows' => 3,
166-
'hint' => esc_html__( 'This is the text that appears as a description within the forms. Leave blank if not needed.', 'wp-user-manager' )
166+
'hint' => esc_html__( 'This is the text that appears as a description within the forms. Leave blank if not needed.', 'wp-user-manager' ),
167167
),
168-
'user_meta_key' => array(
168+
'user_meta_key' => array(
169169
'type' => 'input',
170170
'inputType' => 'text',
171171
'label' => esc_html__( 'Unique meta key', 'wp-user-manager' ),
172172
'model' => 'user_meta_key',
173173
'required' => true,
174174
'hint' => esc_html__( 'The key must be unique for each field and written in lowercase with an underscore ( _ ) separating words e.g country_list or job_title. This will be used to store information about your users into the database of your website.', 'wp-user-manager' ),
175175
'validator' => [ 'string' ],
176-
'min' => 1
176+
'min' => 1,
177177
),
178-
'placeholder' => array(
178+
'placeholder' => array(
179179
'type' => 'input',
180180
'inputType' => 'text',
181181
'label' => esc_html__( 'Placeholder', 'wp-user-manager' ),
182182
'model' => 'placeholder',
183183
'hint' => esc_html__( 'This text will appear within the field when empty. Leave blank if not needed.', 'wp-user-manager' ),
184184
),
185185
],
186-
'validation' => [
186+
'validation' => [
187187
'required' => array(
188188
'type' => 'checkbox',
189189
'label' => esc_html__( 'Set as required', 'wp-user-manager' ),
190190
'model' => 'required',
191191
'default' => false,
192192
'hint' => esc_html__( 'Enable this option so the field must be filled before the form can be processed.', 'wp-user-manager' ),
193-
)
193+
),
194194
],
195-
'privacy' => [
195+
'privacy' => [
196196
'visibility' => array(
197-
'type' => 'radios',
198-
'label' => esc_html__( 'Profile visibility', 'wp-user-manager' ),
199-
'model' => 'visibility',
200-
'hint' => esc_html__( 'Set the visibility of this field on users profiles.', 'wp-user-manager' ),
201-
'values' => [
197+
'type' => 'radios',
198+
'label' => esc_html__( 'Profile visibility', 'wp-user-manager' ),
199+
'model' => 'visibility',
200+
'hint' => esc_html__( 'Set the visibility of this field on users profiles.', 'wp-user-manager' ),
201+
'values' => [
202202
[ 'value' => 'public', 'name' => esc_html__( 'Publicly visible', 'wp-user-manager' ) ],
203-
[ 'value' => 'hidden', 'name' => esc_html__( 'Hidden', 'wp-user-manager' ) ]
203+
[ 'value' => 'hidden', 'name' => esc_html__( 'Hidden', 'wp-user-manager' ) ],
204204
],
205205
'noneSelectedText' => '',
206-
'hideNoneSelectedText' => true,
207-
)
206+
'hideNoneSelectedText' => true,
207+
),
208208
],
209209
'permissions' => [
210-
'editing' => array(
211-
'type' => 'radios',
212-
'label' => esc_html__( 'Profile editing', 'wp-user-manager' ),
213-
'model' => 'editing',
214-
'hint' => esc_html__( 'Set who can edit this field. Hidden fields will not be editable within the front-end account page.', 'wp-user-manager' ),
210+
'editing' => array(
211+
'type' => 'radios',
212+
'label' => esc_html__( 'Profile editing', 'wp-user-manager' ),
213+
'model' => 'editing',
214+
'hint' => esc_html__( 'Set who can edit this field. Hidden fields will not be editable within the front-end account page.', 'wp-user-manager' ),
215215
'values' => [
216216
[ 'value' => 'public', 'name' => esc_html__( 'Publicly editable', 'wp-user-manager' ) ],
217-
[ 'value' => 'hidden', 'name' => esc_html__( 'Hidden (admins only)', 'wp-user-manager' ) ]
217+
[ 'value' => 'hidden', 'name' => esc_html__( 'Hidden (admins only)', 'wp-user-manager' ) ],
218218
],
219219
),
220220
'read_only' => array(
@@ -223,8 +223,17 @@ protected function get_default_editor_settings() {
223223
'model' => 'read_only',
224224
'default' => false,
225225
'hint' => esc_html__( 'Enable to prevent users from editing this field. Note: if the profile editing option is set to publicly editable, the field will still be visible within the account page but will not be customizable.', 'wp-user-manager' ),
226-
)
227-
]
226+
),
227+
'roles' => array(
228+
'type' => 'multiselect',
229+
'label' => esc_html__( 'Allowed Roles', 'wp-user-manager' ),
230+
'model' => 'roles',
231+
'default' => array(),
232+
'options' => wpum_get_roles( true, true ),
233+
'multiple' => true,
234+
'hint' => esc_html__( 'Show the field on the profile and account pages to users with the selected roles.', 'wp-user-manager' ),
235+
),
236+
],
228237
];
229238

230239
if ( $this->allow_default ) {

0 commit comments

Comments
 (0)