Hi I am working on a frontend admin where a user must be able to delete his account. current_user()
is a custom made function of me that retrieves the user meta data.
Does anyone know how I can make this work?
echo '<a class="remove" href="' . get_permalink() . '?remove_account">' . __( 'Click here to remove your account' ) . '</a>';
// Remove account
function terminate_account() {
require_once( ABSPATH . 'wp-admin/includes/user.php' );
wp_delete_user( current_user( 'ID' ) );
}
if( isset( $_GET['remove_account'] ) ) {
add_action( 'init', 'terminate_account' );
}
Taken directly form the
wp_delete_user
documentation:Things to note:
edit:
If you can place this in your themes function file: