Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Ability to delete user account itself (important for germans!)


Print Track
Because of the new privacy policy etc. for example in germany, german need the opportunity that users from a site can unsubscribe and delete himself. Is there a way in Version 9? This is very important and will be prosecuted in Germany.

there is a hack but only version for 7 no longer works

9 replies

Make a user module. The SQL Execution of it is:
CodeDownload  

if (iMEMBER && isset($_POST['delete_me']) {
dbquery("DELETE FROM ".DB_USERS." WHERE user_id=fusion_get_userdata('user_id'));
addNotice('success', 'Bye Bye', 'all);
}



The button for it is:

CodeDownload  

form_button('delete_me', "Delete Me", "delete_me"));

in what folder i have to look and what files i have to make?

includes/userfields/.... ?
Yes, and you need to code the POST execution SQL part in display_user_fields.
plz add this in core well its important for other country's too in future.
includes/user_fields/
make file
user_delus_include_var.php

CodeDownload  
<?php
if (!defined("IN_FUSION")) {
    die("Access Denied");
}

// Version of the user fields api
$user_field_api_version = "1.01.00";
$user_field_name = $locale['uf_delus'];
$user_field_desc = $locale['uf_delus_desc'];
$user_field_dbname = "user_delus";
$user_field_group = 1;
$user_field_dbinfo = "VARCHAR(2) NOT NULL DEFAULT ''";



Make file
user_delus_include.php

CodeDownload  
<?php
if (!defined("IN_FUSION")) {
    die("Access Denied");
}

// Display user field input
if ($profile_method == "input") {
    $user_fields = '';
    if (defined('ADMIN_PANEL')) {
        $user_fields = "<div class='well m-t-5 text-center'>".$locale['uf_delus']."</div>";
    }

// Display in profile
} elseif ($profile_method == "display") {
if (iMEMBER && isset($_POST['delete_me']) && fusion_get_userdata('user_id') == $_GET['lookup']) {
$data = fusion_get_userdata('user_id');

                if (db_exists(DB_ARTICLES)) {
                    dbquery("DELETE FROM ".DB_ARTICLES." WHERE article_name='".$data."'");
                }
                dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_name='".$data."'");
                dbquery("DELETE FROM ".DB_MESSAGES." WHERE message_to='".$data."' OR message_from='".$data."'");
                if (db_exists(DB_NEWS)) {
                    dbquery("DELETE FROM ".DB_NEWS." WHERE news_name='".$data."'");
                }
                if (db_exists(DB_POLL_VOTES)) {
                    dbquery("DELETE FROM ".DB_POLL_VOTES." WHERE vote_user='".$data."'");
                }
                dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_user='".$data."'");
                dbquery("DELETE FROM ".DB_SUSPENDS." WHERE suspended_user='".$data."'");
                if (db_exists(DB_FORUM_THREADS)) {
                    dbquery("DELETE FROM ".DB_FORUM_THREADS." WHERE thread_author='".$data."'");
                }
                if (db_exists(DB_FORUM_POSTS)) {
                    dbquery("DELETE FROM ".DB_FORUM_POSTS." WHERE post_author='".$data."'");
                }
                if (db_exists(DB_FORUM_THREAD_NOTIFY)) {
                    dbquery("DELETE FROM ".DB_FORUM_THREAD_NOTIFY." WHERE notify_user='".$data."'");
                }
                dbquery("DELETE FROM ".DB_USERS." WHERE user_id='".$data."'");

addNotice('success', $locale['uf_delus_exit']);
redirect('index.php');
}

if (iMEMBER && fusion_get_userdata('user_id') == $_GET['lookup']) {
$action_url = FUSION_SELF.(FUSION_QUERY ? "?".FUSION_QUERY : "");
$ab = openform('delete_me', 'post', $action_url);
$ab .= form_button('delete_me', $locale['uf_delus_del'], "delete_me");
$ab .= closeform();
        $user_fields = array('title' => $locale['uf_delus'], 'value' => $ab);

}

}



make file
locale/xxx/user_fields/user_delus.php

CodeDownload  
<?php
$locale['uf_delus'] = "Delete User";
$locale['uf_delus_desc'] = "Delete User";
$locale['uf_delus_del'] = "Delete Me";
$locale['uf_delus_exit'] = "Acount Deleted...";

Got it , done.

There: https://github.com/php-fusion/PHP-Fusion/commit/beb01755dd3bedef73f26018466cd76242eb4dcf
Please change it
Administration error (user_field)

CodeDownload  
} elseif ($profile_method == "display") {


below
CodeDownload  
  if (!defined('ADMIN_PANEL')) {



and last row

CodeDownload  
}

This is current full code:

CodeDownload  

<?php
if (!defined("IN_FUSION")) {
    die("Access Denied");
}

// Display user field input
if ($profile_method == "input") {

    $user_fields = '';
    if (defined('ADMIN_PANEL')) {
        $user_fields = "<div class='well m-t-5 text-center'>".$locale['uf_delete']."</div>";
    }

// Display in profile
} elseif ($profile_method == "display") {

    if (iMEMBER && isset($_POST['delete_me']) && fusion_get_userdata('user_id') == $_GET['lookup'] && !iSUPERADMIN) {
        $data = fusion_get_userdata('user_id');

        if (db_exists(DB_ARTICLES)) {
            dbquery("DELETE FROM ".DB_ARTICLES." WHERE article_name='".$data."'");
        }
        dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_name='".$data."'");
        dbquery("DELETE FROM ".DB_MESSAGES." WHERE message_to='".$data."' OR message_from='".$data."'");
        if (db_exists(DB_NEWS)) {
            dbquery("DELETE FROM ".DB_NEWS." WHERE news_name='".$data."'");
        }
        if (db_exists(DB_POLL_VOTES)) {
            dbquery("DELETE FROM ".DB_POLL_VOTES." WHERE vote_user='".$data."'");
        }
        dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_user='".$data."'");
        dbquery("DELETE FROM ".DB_SUSPENDS." WHERE suspended_user='".$data."'");
        if (db_exists(DB_FORUM_THREADS)) {
            dbquery("DELETE FROM ".DB_FORUM_THREADS." WHERE thread_author='".$data."'");
        }
        if (db_exists(DB_FORUM_POSTS)) {
            dbquery("DELETE FROM ".DB_FORUM_POSTS." WHERE post_author='".$data."'");
        }
        if (db_exists(DB_FORUM_THREAD_NOTIFY)) {
            dbquery("DELETE FROM ".DB_FORUM_THREAD_NOTIFY." WHERE notify_user='".$data."'");
        }
        dbquery("DELETE FROM ".DB_USERS." WHERE user_id='".$data."'");

        addNotice('success', $locale['uf_delete_exit']);
        redirect('index.php');
    }

    if (iMEMBER && fusion_get_userdata('user_id') == $_GET['lookup'] && !iSUPERADMIN) {
        $action_url = FUSION_SELF.(FUSION_QUERY ? "?".FUSION_QUERY : "");
        $ab = openform('delete_me', 'post', $action_url);
        $ab .= form_button('delete_me', $locale['uf_delete_del'], "delete_me");
        $ab .= closeform();
        $user_fields = array('title' => $locale['uf_delete'], 'value' => $ab);
    }

}



Which one? Can paste me full code?

Karrak, please get Github account.. lol
Full code

CodeDownload  
<?php
if (!defined("IN_FUSION")) {
    die("Access Denied");
}

// Display user field input
if ($profile_method == "input") {

    $user_fields = '';
    if (defined('ADMIN_PANEL')) {
        $user_fields = "<div class='well m-t-5 text-center'>".$locale['uf_delete']."</div>";
    }

// Display in profile
} elseif ($profile_method == "display") {
    if (!defined('ADMIN_PANEL')) {

    if (iMEMBER && isset($_POST['delete_me']) && fusion_get_userdata('user_id') == $_GET['lookup'] && !iSUPERADMIN) {
        $data = fusion_get_userdata('user_id');

        if (db_exists(DB_ARTICLES)) {
            dbquery("DELETE FROM ".DB_ARTICLES." WHERE article_name='".$data."'");
        }
        dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_name='".$data."'");
        dbquery("DELETE FROM ".DB_MESSAGES." WHERE message_to='".$data."' OR message_from='".$data."'");
        if (db_exists(DB_NEWS)) {
            dbquery("DELETE FROM ".DB_NEWS." WHERE news_name='".$data."'");
        }
        if (db_exists(DB_POLL_VOTES)) {
            dbquery("DELETE FROM ".DB_POLL_VOTES." WHERE vote_user='".$data."'");
        }
        dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_user='".$data."'");
        dbquery("DELETE FROM ".DB_SUSPENDS." WHERE suspended_user='".$data."'");
        if (db_exists(DB_FORUM_THREADS)) {
            dbquery("DELETE FROM ".DB_FORUM_THREADS." WHERE thread_author='".$data."'");
        }
        if (db_exists(DB_FORUM_POSTS)) {
            dbquery("DELETE FROM ".DB_FORUM_POSTS." WHERE post_author='".$data."'");
        }
        if (db_exists(DB_FORUM_THREAD_NOTIFY)) {
            dbquery("DELETE FROM ".DB_FORUM_THREAD_NOTIFY." WHERE notify_user='".$data."'");
        }
        dbquery("DELETE FROM ".DB_USERS." WHERE user_id='".$data."'");

        addNotice('success', $locale['uf_delete_exit']);
        redirect('index.php');
    }

    if (iMEMBER && fusion_get_userdata('user_id') == $_GET['lookup'] && !iSUPERADMIN) {
        $action_url = FUSION_SELF.(FUSION_QUERY ? "?".FUSION_QUERY : "");
        $ab = openform('delete_me', 'post', $action_url);
        $ab .= form_button('delete_me', $locale['uf_delete_del'], "delete_me");
        $ab .= closeform();
        $user_fields = array('title' => $locale['uf_delete'], 'value' => $ab);
       }
    }

}

author Catzenjaeger
forumUser Administration - 9
replies10 posts
viewed1,977 times
activeLast updated on 3 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Catzenjaeger, Chan, karrak