Self -delete Option?

Discussion in 'Templates customization' started by sunseapromos, Mar 12, 2011.

  1. sunseapromos

    sunseapromos Member

    Joined:
    Apr 26, 2010
    Messages:
    72
    Our site is set up so that it simply consists of one membership level, no products per se.

    So we would like to make an option (preferably on the member's Profile page) where they can delete their account if they desire.

    We are presenting it so they must receive our email communications as long as they are a member, but if they don't want to receive our emails they need to and "can" delete their accounts.

    Can you give me some code to place on the member's profile page that they could hit a button and do this?

    Thank you, :)
    Claudia
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Theres already an option to not receive email on the members page- generally a bad idea to delete an account- this is proof that they opted in to start with, in case they later claimed you are spamming them.

    David
  3. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    here is how you can delete current logged in user in aMember:
    PHP:
    $db->delete_user($_SESSION[_amember_id]);
  4. Desiderius

    Desiderius New Member

    Joined:
    Nov 4, 2006
    Messages:
    24
    I want to add an Link to delete membership in useful links on member_main.html page, so that every user can delete his membership himself.

    Do you have an Idea to resolve this?
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This can be done using get_left_member_links hook:
    PHP:
    setup_plugin_hook("get_left_member_links""show_link");
    function 
    show_link($user){
        global 
    $config;
        return 
    "<a href='".$config[root_url]."/delete.php'>Delete membership</a>";
    }

  6. hnorris

    hnorris aMember Pro Customer

    Joined:
    Sep 1, 2011
    Messages:
    21
    Hello

    We are using 3.4.2PRO.

    Can you please tell me where and in which file I need to put the above code please.

    Thanks
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Put it to /amember/site.inc.php
  8. hnorris

    hnorris aMember Pro Customer

    Joined:
    Sep 1, 2011
    Messages:
    21
    Thanks, I can see the link. However what needs to be put in delete.php ?

    I created it and pasted this into the file
    $db
    ->
    delete_user
    (
    $_SESSION
    [
    _amember_id
    ]);


    However, I get an error : Notice: Undefined variable: db in /sites/LV1VGK/amember/delete.php on line 2 Fatal error: Call to a member function delete_user() on a non-object in /sites/LV1VGK/amember/delete.php on line 2

    I am no php guru sorry !

    Having a delete account link on the site is a legal obligation in France, so any help you can give me would be great.

    Thanks

  9. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    use
    PHP:
    global $db;
    before your code.
    Nedless to say to have to include amember's config.inc.php as well
  10. hnorris

    hnorris aMember Pro Customer

    Joined:
    Sep 1, 2011
    Messages:
    21
    Thanks I now have this :

    PHP:
    <?php
    $rd 
    dirname(__FILE__);
    include(
    $rd.'/config.inc.php');
    global 
    $db;
    $db->delete_user($_SESSION[_amember_id]);
    echo 
    '<div style="text-align: center; font-family: Verdana;">Votre compte et toutes vous donn&eacute;es ont &eacute;t&eacute; supprim&eacute;s.<br>Cliquez <a style="font-weight: bold;"href="http://www.linuxelearning.com">ici</a> pour retourner &agrave; l\'accueil du site.<br></div>';
    ?>
    And it seems to work fine

    Regards
  11. hnorris

    hnorris aMember Pro Customer

    Joined:
    Sep 1, 2011
    Messages:
    21
    Hello again

    We are moving to Amember v2. Can you tell me how and where to add code to get the same delete function ?

    Thanks in advance
  12. hnorris

    hnorris aMember Pro Customer

    Joined:
    Sep 1, 2011
    Messages:
    21
    Sorry All. In the above please read AMember v4.1.15 as opposed to v2 !

Share This Page