Skip to:
Content
Pages
Categories
Search
Top
Bottom

Notification when a user deletes himself.


  • Reiner
    Participant

    @reiner1

    Is there a way for the admins to be notified if a user deletes themselves?

    Many greetings
    Reiner

Viewing 4 replies - 1 through 4 (of 4 total)

  • Venutius
    Moderator

    @venutius

    Hi Reiner,

    There’s a hook you could use to fire n email:

    do_action( 'bp_core_deleted_account', $user_id );


    Reiner
    Participant

    @reiner1

    @venutius

    Thank you for your help.

    In which file do I have to enter this? (function.php?)

    Do I then have to enter something to whom the email should be sent?

    Many greetings
    Reiner


    Venutius
    Moderator

    @venutius

    Hi Reiner, I’ve got two options for you. Firstly I’ve built this into a plugin of mine – BP Messaging Control – https://wordpress.org/plugins/bp-messaging-control/

    So that’s the easy option.

    The alternative is to add this code to your functions.php file in your child theme folder:

    function venutius_user_deletion_notify( $user_id ) {
    	
    	$site_admin_email = get_option( 'admin_email' );
    	$userdata = get_userdata( $user_id );
    	$subject = __( 'User deleted', 'bp-messaging-control' ) . ': "' . $userdata->user_login . '"';
    	$message = __( 'A user has been deleted.', 'bp-messaging-control' );
    	$message .= "\r\n\r\n";
    	$message .= __( 'User Name', 'bp-messaging-control' ) . ': ' . $userdata->user_login . "\r\n";
    	$message .= __( 'User ID', 'bp-messaging-control' ) . ': ' . $user_id . "\r\n";
    	$result = wp_mail( $site_admin_email, $subject, $message );
    	
    }
    add_action( 'bp_core_pre_delete_account', 'venutius_user_deletion_notify', 10 );

    Reiner
    Participant

    @reiner1

    Many Thanks,

    I installed the 2nd solution and it works fine.

    Many greetings
    Reiner

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar