Advertisement:

Author Topic: delete user in oc-admin using osc_add_hook('delete_user', 'function_name')  (Read 538 times)

FredrickReuben

  • Newbie
  • *
  • Posts: 24
Hello..I have a class which is surppost to delete user related folders when user is deleted both from oc-admin and the website. here are my code
Code: [Select]
public function __construct($user_id) {
          $this->delete_dir($user_id);
}

this is the class object that runs when class is called.
Code: [Select]
function user_removed($user_id){

  require_once(osc_plugins_path() . 'easy-avatar/includes/class-easy-avatar-delete-user.php');
return delete_user::newInstance($user_id);

 }
 osc_add_hook('delete_user', 'user_removed');
how can i achive this both in front end and backend
« Last Edit: June 23, 2016, 06:21:58 pm by FredrickReuben »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Hi,

Is it that second function what should be executed on delete user? ??? Because its name ("removed") doesn't match what you're calling on the hook line ("user_removed").

Regards

FredrickReuben

  • Newbie
  • *
  • Posts: 24
Teseo that was an erro in typing. however, after playing around with it, I found this.
Code: [Select]
$user = '';
  $user_id = '';
 
  if(!OC_ADMIN){
  $user = osc_user();
  $user_id = $user['pk_i_id'];//gets the current user id

  }else{
  $user = Params::getParam('id');
  $user_id =  $user['0'];

  }
it works perfectly..any suggestion???
« Last Edit: June 23, 2016, 06:31:00 pm by FredrickReuben »

teseo

  • Hero Member
  • *****
  • Posts: 6169
If you want it simplified, I think:

Code: [Select]
if(!OC_ADMIN) $user_id = osc_user_id();//gets the current user id
else $user_id = Params::getParam('id');

or just a one-liner:

Code: [Select]
$user_id = ( !OC_ADMIN ? osc_user_id() : Params::getParam('id') );

Regards

FredrickReuben

  • Newbie
  • *
  • Posts: 24
works too thyank you