Hooking into admin/user page...
Hi There,
I am just starting working on a module that interfaces with anti forum spam APIs, initially the one at StopForumSpam.org (SFS) and hopefully others in the future. This is my first proper module so pls be gentle!
I plan to hook new signups with hook_user('insert'), check their details against SFS's blacklist and then cache this spam score/status in a table indexed by UID.
I also plan on providing a few admin options to activate/deactivate accounts based on a user specified spam threshold.
I'm fairly clear on how to go about that so far however, what I'd also like to do is display the spam score/status as a column in the admin/user page. I've had a look through the API docs and the user module source code and I don't see how I can do this without hacking at the core modules.
Can anyone who's more seasoned in this type of thing tell me if this is even possible? I have read that there's no way to extend or override a function in a core module in Drupal unless somebody has had the foresight to build the relevant hooks in already so I guess what I'm asking is: Is there a relevant hook I haven't spotted or am I screwed here?
Obviously I can just make a patch to the user module and hack away but that would make it hard to distribute and surely that's half the point of a modular system?
I'm shooting for Drupal 7. Anyone know if this is in code freeze now?
Regards,
Roger Heathcote.

This is very much possible and easy to implement.
This is very much possible and easy to implement without touching the core module.
Here it goes.
Firstly you need to create a custom module with just one function using hook_user()
function hook_user($op, &$edit, &$account, $category = NULL)
the actual code goes like this :
code :
<?phpfunction youModuleName_user($op, &$edit, &$account, $category = NULL)
{
switch ($op)
{
case 'validate':
///check against SFS's blacklist code
if($blacklisted)
form_set_error('','Your error messages');
}
}
?>
The above code will handle everything..
Hi There
Thanks but I'm there already, that bit's not the problem. What I want to know is if there's a way to 'display the spam score/status as a column in the admin/user page.' without getting messy.
I can't see how this is possible as I would have to get the code that generates this page to also grab data from another table and Drupal provides no way to override a core module right? I thought I'd ask anyway though in case my understanding is incomplete / just plain wrong or there's some hook / api that I'm not aware of that might help here.
I'm in the same position with some custom forum mods I did a couple of years back when I just started Drupal. With a couple of years knowledge under my belt I decided to tidy the code up and stick it in a module, as per what everyone says is best practice (i.e. never hack core files directly) only to find it's just not possible to override core behaviour from within a Drupal module unless somebody has anticipated exactly what you might need - which naturally is never going to happen.
As far as can see my only alternative is to create and maintain my own fork of the relevant modules which really sucks as all I really need to do is extend or override the function that grabs the data from the database to include the data I need and then alter the template to display it.
Please somebody throw me a bone / tell me I'm missing something!
Roger Heathcote - www.technicalbloke.com