Users - button on edit profile page for delete account themselfs

Wojtek Cesario Posted in Component Development 10 years ago

Hello,

At the beginning I would like to say hello. It is a great project!
I'm trying to get to know its features from a few days, and writes (as I can) new futures. One of them is a button for deleting an account - for the users, located on the edit profile page.

I adapted a button from the admin panel, and this is a code:

<?php

 $timestamp = time();
 $token = ossn_generate_action_token($timestamp);
 ?>
<a class="userdelete" href="https://www.mypage.coml/action/admin/delete/user?guid=<?php echo $user->guid; ?>&ossn_ts=<?php echo $timestamp; ?>&ossn_token=<?php echo $token;?>">DELETE YOUR ACCOUNT</a>

But it turns out that the user probably don't have permission to delete your account. As I log into as admin and modifies the link with firebug - guid to another user, then I can delete his account, so the link works, but I don't know how to adjust the permissions that a user can delete only himself.

Thank you in advance for any suggestions.

PS.

Later I would like to add:

  • Page with public photos (with the highest number of likes divided for the day, week, month, year)

  • I added a few additional fields in the profile, including locations with automatic map from google and I would add filter searching for search people by location.

The columns in the database have already been added. Everything is working, saving, editing, etc. The last thing is create a filter for search user by location (table Users, column location for example)

Best regards,
Wojtek

Replies
Indonesian Arsalan Shah Replied 10 years ago

In action file you need something like

if($user->guid == ossn_loggedin_user()->guid){
   //delete code
}