WebsiteFavorites Plugin - Delete users favorites in db

2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 11, 2015   (RSS)

By Tom - May 9, 2015

Hello,

Is there a way to delete the user's favorites in the website_favorites db?

For example, a user have 50 favorites stored in the website_favorites table.

For some reason, the user cancel his account and I erase him in the user_account.

Is it possible that once I erase him in the user_account, all his favorites stored in the website_favorites table automatically being erased too?

Or I have to manually delete it?

Thanks a lot

By gregThomas - May 11, 2015

Hi Tom,

You could do this by adding the following code when you delete a user's account:

if($userNum){
  mysql_delete($GLOBALS['WSF_TABLENAME'], null, "`createdByUserNum` = '$userNum'");
}

You'd need to set the variable $userNum to the account number of the user who's being deleted.

As this will be deleting records from the database, ensure that you backup your database before you test it with your site.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com