diff --git a/assets/js/src/form/fields/date.jsx b/assets/js/src/form/fields/date.jsx index c2c406b47d..4a510b11f4 100644 --- a/assets/js/src/form/fields/date.jsx +++ b/assets/js/src/form/fields/date.jsx @@ -222,14 +222,13 @@ define([ } render() { const monthNames = window.mailpoet_month_names || []; - + const dateFormats = window.mailpoet_date_formats || {}; const dateType = this.props.field.params.date_type; - - const dateSelects = dateType.split('_'); + const dateSelects = dateFormats[dateType][0].split('/'); const fields = dateSelects.map(type => { switch(type) { - case 'year': + case 'yyyy': return (); break; - case 'month': + case 'mm': return (); break; - case 'day': + case 'dd': return (wp_user_id === null) { + if(!$subscriber || $subscriber->isWPUser() === false) { $queue->delete(); return false; } diff --git a/lib/Subscription/Pages.php b/lib/Subscription/Pages.php index e5111a4ecc..89898a147a 100644 --- a/lib/Subscription/Pages.php +++ b/lib/Subscription/Pages.php @@ -10,6 +10,8 @@ use \MailPoet\Models\Segment; use \MailPoet\Util\Helpers; use \MailPoet\Util\Url; use \MailPoet\Subscription; +use \MailPoet\Form\Renderer as FormRenderer; +use \MailPoet\Form\Block\Date as FormBlockDate; class Pages { const DEMO_EMAIL = 'demo@mailpoet.com'; @@ -220,6 +222,14 @@ class Pages { $custom_field->id = 'cf_'.$custom_field->id; $custom_field = $custom_field->asArray(); $custom_field['params']['value'] = $subscriber->{$custom_field['id']}; + + if($custom_field['type'] === 'date') { + $date_formats = FormBlockDate::getDateFormats(); + $custom_field['params']['date_format'] = $date_formats[ + $custom_field['params']['date_type'] + ][0]; + } + return $custom_field; }, CustomField::findMany()); @@ -257,7 +267,7 @@ class Pages { 'params' => array( 'label' => __('First name'), 'value' => $subscriber->first_name, - 'disabled' => ($subscriber->wp_user_id !== null) + 'disabled' => ($subscriber->isWPUser()) ) ), array( @@ -266,7 +276,7 @@ class Pages { 'params' => array( 'label' => __('Last name'), 'value' => $subscriber->last_name, - 'disabled' => ($subscriber->wp_user_id !== null) + 'disabled' => ($subscriber->isWPUser()) ) ), array( @@ -333,7 +343,7 @@ class Pages { $form_html .= ''; $form_html .= '
'; // special case for WP users as they cannot edit their subscriber's email - if($subscriber->wp_user_id !== null) { + if($subscriber->isWPUser()) { // check if subscriber's associated WP user is the currently logged in WP user $wp_current_user = wp_get_current_user(); if($wp_current_user->user_email === $subscriber->email) { @@ -356,7 +366,7 @@ class Pages { $form_html .= '

'; // subscription form - $form_html .= \MailPoet\Form\Renderer::renderBlocks($form); + $form_html .= FormRenderer::renderBlocks($form); $form_html .= ''; return $form_html; } diff --git a/views/subscribers/subscribers.html b/views/subscribers/subscribers.html index f9dc1c1db2..9addcff5d0 100644 --- a/views/subscribers/subscribers.html +++ b/views/subscribers/subscribers.html @@ -8,6 +8,7 @@ var mailpoet_segments = <%= json_encode(segments) %>; var mailpoet_custom_fields = <%= json_encode(custom_fields) %>; var mailpoet_month_names = <%= json_encode(month_names) %>; + var mailpoet_date_formats = <%= json_encode(date_formats) %>; <% endblock %>