Comment::getAuthorEmail

public Comment::getAuthorEmail()

Returns the comment author's email address.

For anonymous authors, this is the value as typed in the comment form.

Return value

string The email address of the author of the comment.

Overrides CommentInterface::getAuthorEmail

File

core/modules/comment/src/Entity/Comment.php, line 412

Class

Comment
Defines the comment entity class.

Namespace

Drupal\comment\Entity

Code

1
2
3
4
5
6
7
8
9
public function getAuthorEmail() {
  $mail = $this->get('mail')->value;
 
  if ($this->get('uid')->target_id != 0) {
    $mail = $this->get('uid')->entity->getEmail();
  }
 
  return $mail;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.