I'm playing with a plugin to block pm's from specific users but the hook I'm using seems to be useless. I'm trying to use do_message_send PRE/LAST but I don't get any arguments other than the do= parameter - how do I get the pm details like sender, body etc?
Aug 17, 2002, 12:48 AM
Veteran / Moderator (2199 posts)
Aug 17, 2002, 12:48 AM
Post #2 of 5
Views: 1795
I think you don't get the message details as arguments to the sub, rather you have to extract them from $IN. Looking at GForum::Message::send, it says:
my $page = $func->{page};
my $user_id = $IN->param('user');
my $user_username = $IN->param('user_username') if not $user_id;
my $temp_id = $IN->param('temp_id');That gives you the userid or the username of the recipient, and this in turn will allow you to check if the sender is blocked.
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Code:
my ($do, $func) = @_; my $page = $func->{page};
my $user_id = $IN->param('user');
my $user_username = $IN->param('user_username') if not $user_id;
my $temp_id = $IN->param('temp_id');
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Aug 17, 2002, 2:14 AM
Veteran / Moderator (2199 posts)
Aug 17, 2002, 2:14 AM
Post #4 of 5
Views: 1785
I think it just a matter of when $IN parameters are actually read and put into an argument for a sub. As far as I can see, all the do_xxxx kind of actions just get the page parameter passed (from the definition of the action), and they have to read all other parameters by themselves. Jason probably has his reasons for doing it like this...
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Aug 17, 2002, 2:26 AM
Veteran (19537 posts)
Aug 17, 2002, 2:26 AM
Post #5 of 5
Views: 1792
Most of my plugins have been for Links SQL which seems to pass arguements to most hooks so maybe thats whats confusing me. As you say I'm sure there's a reason....I suppose if everything is accessible from $IN then you don't need to pass the extra arguments....I guess you only get arguments when something other than input is generated.