Merge pull request #1320 from ultimatemember/feature/delete_comments

Delete comments
This commit is contained in:
Mykyta Synelnikov
2023-10-03 14:42:43 +03:00
committed by GitHub
3 changed files with 18 additions and 1 deletions
@@ -1229,6 +1229,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
'size' => 'small',
),
array(
'id' => 'delete_comments',
'type' => 'checkbox',
'label' => __( 'Deleting user comments after deleting a user', 'ultimate-member' ),
'tooltip' => __( 'Do you want to delete a user\'s comments when that user deletes themself or is removed from the admin dashboard from the site?', 'ultimate-member' ),
),
),
),
'account' => array(
+1
View File
@@ -596,6 +596,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'secure_notify_admins_banned_accounts' => false,
'secure_notify_admins_banned_accounts__interval' => 'instant',
'secure_allowed_redirect_hosts' => '',
'delete_comments' => 0,
);
add_filter( 'um_get_tabs_from_config', '__return_true' );
+11 -1
View File
@@ -569,7 +569,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
/**
* @param $user_id
*/
function delete_user_handler( $user_id ) {
public function delete_user_handler( $user_id ) {
um_fetch_user( $user_id );
$this->deleted_user_id = $user_id;
@@ -613,6 +613,16 @@ if ( ! class_exists( 'um\core\User' ) ) {
*/
do_action( 'um_delete_user', um_user( 'ID' ) );
// remove user's comments
if ( UM()->options()->get( 'delete_comments' ) ) {
$user = get_user_by( 'id', um_user( 'ID' ) );
$comments = array_merge( get_comments( 'author_email=' . $user->user_email ), get_comments( 'user_id=' . um_user( 'ID' ) ) );
foreach ( $comments as $comment ) {
wp_delete_comment( $comment->comment_ID, true );
}
}
// send email notifications
if ( $this->send_mail_on_delete ) {
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );