Skip to content

Commit

Permalink
Pre-populate name/email fields on Add new subscription form; See: wps…
Browse files Browse the repository at this point in the history
  • Loading branch information
kristineds committed Jan 28, 2016
1 parent e0e01a4 commit 19b60eb
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions comment-mail-pro/includes/classes/sub-manage-sub-form-base.php
Expand Up @@ -252,6 +252,55 @@ public function current_value_for($key_prop)
if(!empty($current_email_latest_info->{$key_prop}))
return trim((string)$current_email_latest_info->{$key_prop});

if(!$this->is_edit && !static::$processing && in_array($key_prop, array('fname', 'lname', 'email'), TRUE)) {
// We can try to autofill fname, lname, email for new subscriptions.
$current = wp_get_current_commenter();

switch($key_prop) {
case 'fname':
if(!empty($current['comment_author'])) {
return $this->plugin->utils_string->first_name((string)$current['comment_author']);
}
break;

case 'lname':
if(!empty($current['comment_author'])) {
return $this->plugin->utils_string->last_name((string)$current['comment_author']);
}
break;

case 'email':
if(!empty($current['comment_author_email'])) {
return (string)$current['comment_author_email'];
}
break;
}
}
if(!$this->is_edit && !static::$processing && in_array($key_prop, array('fname', 'lname', 'email'), TRUE)) {
// We can try to autofill fname, lname, email for new subscriptions.
$current = wp_get_current_user();

switch($key_prop) {
case 'fname':
if(!empty($current->first_name)) {
return $this->plugin->utils_string->first_name((string)$current->first_name);
}
break;

case 'lname':
if(!empty($current->last_name)) {
return $this->plugin->utils_string->last_name((string)$current->last_name);
}
break;

case 'email':
if(!empty($current->email)) {
return (string)$current->email;
}
break;
}
}

if(!$this->is_edit && !static::$processing && in_array($key_prop, array('fname', 'lname', 'email'), TRUE)) {
// We can try to autofill fname, lname, email for new subscriptions.
$current = wp_get_current_commenter();
Expand Down

0 comments on commit 19b60eb

Please sign in to comment.