Prevent deleting own account if currently login

Hello everyone I’m using phprad classic and I would like to ask on how to prevent deleting own account if an admin currently login and have access on page list account.

Example: admin2 currently login and then have access in page list of accounts next is if I delete my own account which admin2. Restrict it or don’t allow to delete because I’m currently login.

Thank you :blush:

For a Classic project, the following code should do the trick. The following code should be added to the user table in Page EventsBeforeDelete.

$arr_id = explode(",", $rec_id);

if(in_array(auth()->user()->fieldname, $arr_id)) {
    return $this->redirect($redirectUrl, "You cannot delete your account.");

Please note that in the code, you must replace “fieldname” with your user table ID field name.

1 Like

Thank You for very fast response❤️

Code Not Working =( i try all possible solution not working, try it bro in yourself not working

sorry bro for checking solution hahahha because when i try the code it didn’t work haha

You are applying a Radsystems Studio code to PHPRad Classic 2.7.3, and that won’t work. Please use the right forum PHPRad Classic Initial 2.7.3 Forum - Index, to get the right information you want.