disabled first/last name inputs for WP User on manage subscription page
This commit is contained in:
@ -81,6 +81,16 @@ class Hooks {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manage subscription
|
||||||
|
add_action(
|
||||||
|
'admin_post_mailpoet_subscription_update',
|
||||||
|
'\MailPoet\Subscription\Manage::onSave'
|
||||||
|
);
|
||||||
|
add_action(
|
||||||
|
'admin_post_nopriv_mailpoet_subscription_update',
|
||||||
|
'\MailPoet\Subscription\Manage::onSave'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupWPUsers() {
|
function setupWPUsers() {
|
||||||
|
@ -116,11 +116,11 @@ abstract class Base {
|
|||||||
protected static function getInputModifiers($block = array()) {
|
protected static function getInputModifiers($block = array()) {
|
||||||
$modifiers = array();
|
$modifiers = array();
|
||||||
|
|
||||||
if(isset($block['params']['readonly'])) {
|
if(isset($block['params']['readonly']) && $block['params']['readonly']) {
|
||||||
$modifiers[] = 'readonly';
|
$modifiers[] = 'readonly';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($block['params']['disabled'])) {
|
if(isset($block['params']['disabled']) && $block['params']['disabled']) {
|
||||||
$modifiers[] = 'disabled';
|
$modifiers[] = 'disabled';
|
||||||
}
|
}
|
||||||
return join(' ', $modifiers);
|
return join(' ', $modifiers);
|
||||||
|
@ -7,6 +7,7 @@ class Manage {
|
|||||||
|
|
||||||
static function onSave() {
|
static function onSave() {
|
||||||
$action = (isset($_POST['action']) ? $_POST['action'] : null);
|
$action = (isset($_POST['action']) ? $_POST['action'] : null);
|
||||||
|
|
||||||
if($action !== 'mailpoet_subscription_update') {
|
if($action !== 'mailpoet_subscription_update') {
|
||||||
Url::redirectBack();
|
Url::redirectBack();
|
||||||
}
|
}
|
||||||
|
@ -249,13 +249,15 @@ class Pages {
|
|||||||
);
|
);
|
||||||
}, $segments);
|
}, $segments);
|
||||||
|
|
||||||
|
|
||||||
$fields = array(
|
$fields = array(
|
||||||
array(
|
array(
|
||||||
'id' => 'first_name',
|
'id' => 'first_name',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
'label' => __('First name'),
|
'label' => __('First name'),
|
||||||
'value' => $subscriber->first_name
|
'value' => $subscriber->first_name,
|
||||||
|
'disabled' => ($subscriber->wp_user_id !== null)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -263,7 +265,8 @@ class Pages {
|
|||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
'label' => __('Last name'),
|
'label' => __('Last name'),
|
||||||
'value' => $subscriber->last_name
|
'value' => $subscriber->last_name,
|
||||||
|
'disabled' => ($subscriber->wp_user_id !== null)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -329,12 +332,23 @@ class Pages {
|
|||||||
$form_html .= '<p class="mailpoet_paragraph">';
|
$form_html .= '<p class="mailpoet_paragraph">';
|
||||||
$form_html .= '<label>Email *<br /><strong>'.$subscriber->email.'</strong></label>';
|
$form_html .= '<label>Email *<br /><strong>'.$subscriber->email.'</strong></label>';
|
||||||
$form_html .= '<br /><span style="font-size:85%;">';
|
$form_html .= '<br /><span style="font-size:85%;">';
|
||||||
|
// special case for WP users as they cannot edit their subscriber's email
|
||||||
if($subscriber->wp_user_id !== null) {
|
if($subscriber->wp_user_id !== null) {
|
||||||
$form_html .= str_replace(
|
// check if subscriber's associated WP user is the currently logged in WP user
|
||||||
array('[link]', '[/link]'),
|
$wp_current_user = wp_get_current_user();
|
||||||
array('<a href="'.wp_login_url().'" target="_blank">', '</a>'),
|
if($wp_current_user->user_email === $subscriber->email) {
|
||||||
__('[link]Log in to your account[/link] to update your email.')
|
$form_html .= str_replace(
|
||||||
);
|
array('[link]', '[/link]'),
|
||||||
|
array('<a href="'.get_edit_profile_url().'" target="_blank">', '</a>'),
|
||||||
|
__('[link]Edit your profile[/link] to update your email.')
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$form_html .= str_replace(
|
||||||
|
array('[link]', '[/link]'),
|
||||||
|
array('<a href="'.wp_login_url().'" target="_blank">', '</a>'),
|
||||||
|
__('[link]Log in to your account[/link] to update your email.')
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$form_html .= __('Need to change your email address? Unsubscribe here, then simply sign up again.');
|
$form_html .= __('Need to change your email address? Unsubscribe here, then simply sign up again.');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user