By KayBe on
I've created a view with for each item in the view a button that redirects to a url action/inactivate/user/5
How can I run the function to inactivate user nr 5?
Can this be done with Rules module?
Regards,
Kris
I've created a view with for each item in the view a button that redirects to a url action/inactivate/user/5
How can I run the function to inactivate user nr 5?
Can this be done with Rules module?
Regards,
Kris
Comments
You have need to define menu item first.
Hi Kris,
To perform any action on url, you have need to define menu item for that.
After based on that menu item, you can write your function.
Please check below, I have tried to explain. put your logic in custom_inactive_user function.
Thanks,
Kuldip Gohil
http://www.spreaddrupal.org
Didn't thought it was that
Didn't thought it was that easy... Thanks Kuldip!
It doesn't seem to work
It doesn't seem to work out.
This is my code
Her is my url:
http://localhost/xxxxxxxCoworking/action/approve/user/105/16
The result:
The requested page "/xxxxxxxCoworking/action/approve/user/105/16" could not be found.
What is wrong with the code?
Rebuild menu, If that does
Rebuild menu,
If that does not solve, this might be the problem:
'load arguments' => array(4),
Do you have a compid_load function somewhere or not?
Remove the load arguments, rebuild menu and check.
And 'page arguments' => array(3, 4),
I called all the caches with
I called all the caches with drush.
I also changed the code to this for testing;
But no luck either.
I dont't have a compid_load(). Is that needed?
Regards,
Kris
It was needed for load
It was needed for load arguments, anyways now you go and check the menu_router table in the database whether this action/approve/user/%userid exists there or not. If it does not exist there then your menu item is not getting inserted in the database.
The code does look okay from my end though. Also check your error logs.
it does not seem to be in the
it does not seem to be in the router_table.
I had an error in another
I had an error in another menu alter function causing the registration to fail. Although it still not works with parameters other than %.
Anyway, I solved it for now using the fact that all parameters are picked up anyway and I can catch them in the page callback function.
Not very nice thing for now. I'll try to figure this out later. If someone has a suggestion for multiple arguments, I would be glad to hear it.
"Registered paths may also
"Registered paths may also contain special "auto-loader" wildcard components in the form of '%mymodule_abc', where the '%' part means that this path component is a wildcard, and the 'mymodule_abc' part defines the prefix for a load function, which here would be named mymodule_abc_load(). When a matching path is requested, your load function will receive as its first argument the path component in the position of the wildcard; load functions may also be passed additional arguments (see "load arguments" in the return value section below)."
http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct...
Try the below
function cowork_menu() {
$items['action/approve/user/%/%'] = array(
'title' => 'Approve User',
'page callback' => 'cowork_approve_user',
'page arguments' => array(3,4),
'access callback' => TRUE,
);
return $items;
}
function cowork_approve_user($userid, $compid) {
return 'here comes the approval request result'.$userid.$compid;
}