Autoaction limit to frontend and direct calls only

6 months 1 week ago #335564 by activha
I have a php file included with my autoaction using the trigger onBeforeDeleteUser.
This file uses the id of the deleted user as this :
$userid = $action->string($user, '[var1_user_id]');
$folders = $action->string($user, '[post_folders]');

$cbUser  = CBuser::getInstance($userid, false);
$token = $cbUser->getUserData()->getString( 'cb_token_api', '0' );

$url = JURI::base() . 'handle-command';

$ndata = [
  'userid' => $userid,  
  'command' => 'erase-user',
  'folders' => $folders
];

All is working fine when a user is deleted, but I would like to use the same php code manually with a button for our mods to trigger the deletion.

In this case, how can I get the user id of the viewed user so that I can pass this to my code ?


 

Please Log in to join the conversation.

6 months 1 week ago #335566 by krileon
Add a GET variable to your URL then link to the auto action and include that GET variable. Example as follows.
index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID&delete=USER_ID

You can then access &delete with [get_delete]. So within your code you could do something like the following.
$userid = (int) $action->string( $user, '[var1_user_id]' );

if ( ! $userid ) {
	$userid = (int) $action->string( $user, '[get_delete]' );
}


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: activha

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.171 seconds

Facebook Twitter LinkedIn