Title: wp_comments_personal_data_exporter
Published: October 5, 2018
Last modified: August 20, 2026

---

# wp_comments_personal_data_exporter( string $email_address, int $page = 1 ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#wp--skip-link--target)

Finds and exports personal data associated with an email address from the comments
table.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#parameters)󠁿

 `$email_address`stringrequired

The comment author email address.

`$page`intoptional

Comment page number.

Default:`1`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#return)󠁿

 array An array of personal data.

 * `data` array[]
 * An array of personal data arrays.
 * `done` bool
 * Whether the exporter is finished.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#source)󠁿

    ```php
    function wp_comments_personal_data_exporter( $email_address, $page = 1 ) {
    	// Limit us to 500 comments at a time to avoid timing out.
    	$number = 500;
    	$page   = (int) $page;

    	$data_to_export = array();

    	$comments = get_comments(
    		array(
    			'author_email'              => $email_address,
    			'number'                    => $number,
    			'paged'                     => $page,
    			'orderby'                   => 'comment_ID',
    			'order'                     => 'ASC',
    			'update_comment_meta_cache' => false,
    		)
    	);

    	$comment_prop_to_export = array(
    		'comment_author'       => __( 'Comment Author' ),
    		'comment_author_email' => __( 'Comment Author Email' ),
    		'comment_author_url'   => __( 'Comment Author URL' ),
    		'comment_author_IP'    => __( 'Comment Author IP' ),
    		'comment_agent'        => __( 'Comment Author User Agent' ),
    		'comment_date'         => __( 'Comment Date' ),
    		'comment_content'      => __( 'Comment Content' ),
    		'comment_link'         => __( 'Comment URL' ),
    	);

    	foreach ( (array) $comments as $comment ) {
    		$comment_data_to_export = array();

    		foreach ( $comment_prop_to_export as $key => $name ) {
    			$value = '';

    			switch ( $key ) {
    				case 'comment_author':
    				case 'comment_author_email':
    				case 'comment_author_url':
    				case 'comment_author_IP':
    				case 'comment_agent':
    				case 'comment_date':
    					$value = $comment->{$key};
    					break;

    				case 'comment_content':
    					$value = get_comment_text( $comment->comment_ID );
    					break;

    				case 'comment_link':
    					$value = get_comment_link( $comment->comment_ID );
    					$value = sprintf(
    						'<a href="%s" target="_blank">%s</a>',
    						esc_url( $value ),
    						esc_html( $value )
    					);
    					break;
    			}

    			if ( ! empty( $value ) ) {
    				$comment_data_to_export[] = array(
    					'name'  => $name,
    					'value' => $value,
    				);
    			}
    		}

    		$data_to_export[] = array(
    			'group_id'          => 'comments',
    			'group_label'       => __( 'Comments' ),
    			'group_description' => __( 'User&#8217;s comment data.' ),
    			'item_id'           => "comment-{$comment->comment_ID}",
    			'data'              => $comment_data_to_export,
    		);
    	}

    	$done = count( $comments ) < $number;

    	return array(
    		'data' => $data_to_export,
    		'done' => $done,
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/comment.php#L4190)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/comment.php#L4190-L4272)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#related)󠁿

| Uses | Description | 
| [get_comment_text()](https://developer.wordpress.org/reference/functions/get_comment_text/)`wp-includes/comment-template.php` |

Retrieves the text of the current comment.

  | 
| [get_comment_link()](https://developer.wordpress.org/reference/functions/get_comment_link/)`wp-includes/comment-template.php` |

Retrieves the link to a given comment.

  | 
| [get_comments()](https://developer.wordpress.org/reference/functions/get_comments/)`wp-includes/comment.php` |

Retrieves a list of comments.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_exporter/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.6](https://developer.wordpress.org/reference/since/4.9.6/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_comments_personal_data_exporter%2F)
before being able to contribute a note or feedback.