Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,32 @@ body {
display: none;
}
}

.ur-advance-setting-group {
border: 1px solid #f0f0f0;
padding: 0.25rem;
position: relative;
display: flex;
align-items: center;
margin-bottom: 1rem;
&.row {
align-items: end;
}
&.column {
flex-direction: column;
}
.ur-legend {
font-weight: 100;
font-size: 0.9rem;
position: absolute;
top: -10px;
left: 10px;
color: #333;
background-color: white;
}
label {
font-size: 0.75rem !important;
}
}
.ur-advance-setting-block {
margin-top: 0;
}
Expand Down
3 changes: 3 additions & 0 deletions assets/css/user-registration.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3106,3 +3106,6 @@ body.user-registration-page {
animation: toaster 5s ease-in-out forwards;
}

.user-registration.ur-frontend-form form.register .d-none {
display: none;
}
77 changes: 76 additions & 1 deletion assets/js/admin/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,79 @@
}
}
);


// Hide sublabels from ur field in case of multiple fields field.
$(document).on('change', '#ur-setting-form [data-field=hide_sublabels]', function() {
if ($(this).is(':checked')) {
$('.ur-input-grids').find('.ur-item-active .ur-field').find('label').addClass('ur-d-none');
} else {
$('.ur-input-grids').find('.ur-item-active .ur-field').find('label').removeClass('ur-d-none');
}
});

// Hide sublabels from ur field in case of multiple fields field.
$(document).on('change', '#ur-setting-form [data-field=hide_sublabels]', function() {
if ($(this).is(':checked')) {
$('.ur-input-grids').find('.ur-item-active .ur-field').find('label').addClass('ur-d-none');
} else {
$('.ur-input-grids').find('.ur-item-active .ur-field').find('label').removeClass('ur-d-none');
}
});

// update placeholder for each sub fields.
var sourceInput = '.ur-advance-setting-group [data-advance-field$="placeholder"]';
$(document).on('input', sourceInput, function () {
var targetInput = '.ur-' + $(this).data('advance-field').replace(/_placeholder$/, '').replace(/_/g, '-') + ' input';
var inputValue = $(this).val();
$(targetInput).attr('placeholder', inputValue);
});


// show/hide sub fields.
$('.ur-advance-setting-group input[type="checkbox"]').each(function() {
var forClass = $(this).is(':checked');
if($(this).is(":checked")) {
$('.ur-input-grids .ur-item-active').find('.' + forClass).addClass('ur-d-none');
} else {
$('.ur-input-grids .ur-item-active').find('.' + forClass).removeClass('ur-d-none');
}
});
$(document).on('change', '.ur-advance-setting-group input[type="checkbox"]', function() {
var forClass = $(this).data('id');
if($(this).is(":checked")) {
$('.ur-input-grids .ur-item-active').find('.' + forClass).addClass('ur-d-none');
} else {
$('.ur-input-grids .ur-item-active').find('.' + forClass).removeClass('ur-d-none');
}
});

// update placeholder for each sub fields.
let sourceInput = '.ur-advance-setting-group [data-advance-field$="placeholder"]';
$(document).on('input', sourceInput, function () {
let targetInput = '.ur-' + $(this).data('advance-field').replace(/_placeholder$/, '').replace(/_/g, '-') + ' input';
let inputValue = $(this).val();
$(targetInput).attr('placeholder', inputValue);
});


// show/hide sub fields.
$('.ur-advance-setting-group input[type="checkbox"]').each(function() {
let forClass = $(this).is(':checked');
if($(this).is(":checked")) {
$('.ur-input-grids .ur-item-active').find('.' + forClass).addClass('ur-d-none');
} else {
$('.ur-input-grids .ur-item-active').find('.' + forClass).removeClass('ur-d-none');
}
});
$(document).on('change', '.ur-advance-setting-group input[type="checkbox"]', function() {
let forClass = $(this).data('id');
if($(this).is(":checked")) {
$('.ur-input-grids .ur-item-active').find('.' + forClass).addClass('ur-d-none');
} else {
$('.ur-input-grids .ur-item-active').find('.' + forClass).removeClass('ur-d-none');
}
});
},
init_user_profile_modal: function () {
var user_profile_modal = {
Expand Down Expand Up @@ -2213,7 +2286,9 @@
switch ($this_node.attr("type")) {
case "checkbox":
value = $this_node.is(":checked");

if ($this_node.data('field') == 'hide_sublabels') {
value = $(document).find('[data-field="hide_sublabels"]').prop('checked');
}
if (
$this_node.hasClass(
"ur-type-checkbox-value"
Expand Down
13 changes: 12 additions & 1 deletion includes/abstracts/abstract-ur-field-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,18 @@ public function render_html($fields)

foreach ($fields as $field_key => $field) {

$tooltip_html = ! empty($field['tip']) ? ur_help_tip($field['tip'], false, 'ur-portal-tooltip') : '';
$tooltip_html = ! empty( $field['tip'] ) ? ur_help_tip( $field['tip'], false, 'ur-portal-tooltip' ) : '';

if( "row" === $field[ 'type' ] ) {
$this->fields_html .= '<div class="ur-advance-setting-group ur-d-flex" style="gap: 0.5rem;"> ';
$this->fields_html .= '<div class="ur-legend">' . $field['label'] . $tooltip_html . '</div>';
$fields_html = $this->fields_html;
$this->render_html( $field['items'] );
$this->fields_html = $fields_html . $this->fields_html;
$this->fields_html .= '</div>';
continue;
}

$smart_tags = '';
if ('default_value' === $field_key) {
/**
Expand Down
10 changes: 10 additions & 0 deletions includes/admin/class-ur-admin-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public function add_upgradable_other_fields() {
'video_id' => 'pzhJ3qjQfC4',
'name' => __( 'User Registration - File Upload', 'user-registration' ),
),
array(
'id' => 'user_registration_address',
'slug' => 'address',
'label' => 'Address',
'video_id' => 'CF_o-xrMXZM',
'plan' => 'Personal Plan',
'icon' => 'ur-icon ur-icon-flag',
'name' => __( 'User Registration Pro', 'user-registration' ),
'field_class' => 'UR_Form_Field_Address',
),
array(
'id' => 'user_registration_invite_code',
'label' => 'Invitation Code',
Expand Down
31 changes: 30 additions & 1 deletion includes/admin/settings/class-ur-users-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,36 @@ private function render_user_form_fields($user_id)
} elseif('membership' === $field_key){
$membership_id = get_user_meta($user->ID, 'user_registration_' . $field_name, true);
$value = get_the_title($membership_id);
} else {
} elseif( 'address' === $field_key ) {
$address = (array)$user_metadata_details;
$address_parts = [];
if ( is_array( $address ) ) {
if ( ! empty( $address['address_line_1'] ) ) {
$address_parts[] = $address['address_line_1'];
}
if ( ! empty( $address['address_line_2'] ) ) {
$address_parts[] = $address['address_line_2'];
}
if ( ! empty( $address['city'] ) ) {
$address_parts[] = $address['city'];
}
if ( ! empty( $address['state'] ) ) {
$address_parts[] = $address['state'];
}
if ( ! empty( $address['zip_code'] ) ) {
$address_parts[] = $address['zip_code'];
}
if ( ! empty( $address['country'] ) ) {
$country_class = ur_load_form_field_class( 'country' );
$countries = $country_class::get_instance()->get_country();
$country_name = isset( $countries[ $address['country'] ] ) ? $countries[ $address['country'] ] : $address['country'];
$address_parts[] = $country_name;
}
$value = implode( ', ', $address_parts );
} else {
$value = '';
}
} else {
$value = get_user_meta($user->ID, 'user_registration_' . $field_name, true);

// For Woocommerce fields.
Expand Down
22 changes: 19 additions & 3 deletions includes/functions-ur-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ function ur_get_field_type( $field_key ) {
case 'country':
$field_type = 'select';
break;
case 'address':
$field_type = 'composite';
break;
case 'file':
$field_type = 'file';
break;
Expand Down Expand Up @@ -833,6 +836,7 @@ function ur_get_registered_form_fields() {
'checkbox',
'privacy_policy',
'radio',
'address',
)
);
}
Expand Down Expand Up @@ -2737,13 +2741,24 @@ function ur_parse_name_values_for_smart_tags( $user_id, $form_id, $valid_form_da

if ( isset( $form_data->field_type ) && 'repeater' === $form_data->field_type ) {
$data_html .= '<td>' . $value . '</td></tr>';
} elseif ( isset( $form_data->extra_params['field_key'] ) && 'signature' === $form_data->extra_params['field_key'] ) {
} elseif ( isset( $form_data->field_type ) && 'address' === $form_data->field_type ) {
$data_html .= '<td>' . json_encode( $value ) . '</td></tr>';
}
elseif ( isset( $form_data->extra_params['field_key'] ) && 'signature' === $form_data->extra_params['field_key'] ) {
$data_html .= '<tr><td>' . $label . ' : </td><td><img class="profile-preview" alt="Signature" width="50px" height="50px" src="' . ( is_numeric( $value ) ? esc_url( wp_get_attachment_url( $value ) ) : esc_url( $value ) ) . '" /></td></tr>';
} else {
$data_html .= '<tr><td>' . $label . ' : </td><td>' . $value . '</td></tr>';
}

$name_value[ $field_name ] = $value;
if( isset( $form_data->field_type ) && 'address' === $form_data->field_type ) {
$name_value[ $field_name ] = json_encode( $value );
} else {
$name_value[ $field_name ] = $value;
}
if( isset( $form_data->field_type ) && 'address' === $form_data->field_type ) {
$name_value[ $field_name ] = json_encode( $value );
} else {
$name_value[ $field_name ] = $value;
}
}

$data_html .= '</tbody></table>';
Expand Down Expand Up @@ -5621,6 +5636,7 @@ function user_registration_validate_form_field_data( $data, $form_data, $form_id

if ( ! empty( $validations ) ) {
if ( in_array( 'required', $validations, true ) || ! empty( $single_field_value ) ) {
$single_field_value = $single_field_value instanceof stdClass ? (array) $single_field_value : $single_field_value;
foreach ( $validations as $validation ) {
$result = UR_Form_Validation::$validation( $single_field_value );

Expand Down
1 change: 1 addition & 0 deletions includes/validation/class-ur-form-validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ public function get_update_profile_validation_skippable_fields( $form_data ) {
'signature',
'membership',
'subscription_plan',
'address',
);

$form_skippable_fields = array_filter(
Expand Down
Loading