Recent Topics

1 Feb 04, 2009 06:31    

So I can use AfterUserUpdate to do stuff after a user updates his or her profile. In my case my plugin is storing login id and login name and website if provided, so this hook lets my plugin track changes to those bits. YAY!

But what happens when someone with powers and abilities promotes a user from group #4 to group #3? How would the current_User (the one with the powers and abilities) access the information about the user that just got updated. Oh yeah my plugin is using the group ID as an important bit. IF the person has paid their contest entry fee then they get more blogging permissions AND I start to keep track of points.

So I either need to figure out how to have AfterUserUpdate know that the current_User is not the one who got updated, or ... ? I opted to keep this info in the plugin instead of just access it because near as I can tell it'll be a lot less querying to make the groovy tables of info on my Tools->plugin subtab.

Something else is on my mind regarding deleting users, but one thing at a time eh?

EDIT: I just noticed a hook named PluginUserSettingsEditAction so perhaps I need to go there, but tomorrow morning comes way too freakin early for me and I'm already way behind on delivering this thing. So I'm hoping someone already dealt with this "user A is updating user B" and how to work that with a plugin business.

2 Feb 04, 2009 07:52

function AfterUserUpdate( $params )
{
  pre_dump( $params['User'] );
}

;)

¥

3 Feb 07, 2009 03:41

Okay that's cool. I was doing pretty good until I noticed a funky little detail that I finally figured out the root cause of.

$params['User']->login shows me the new login if that was changed.
$params['User']->email shows me the new email if that was changed.
$params['User']->url shows me the new website if that was changed.

Here's the bad part:
$params['User']->group_ID shows me the OLD group ID if that was changed.

Now compliments of pre_dump (or print_r but it's all the same really) that part of what shows up is a "[Group] = > Group Object" that happens to contain lots of groovy info about the NEW group, including the new group ID. All I want is the ID, but I can't for the life of me guess how to get a tiny bit out of a group out of a user out of a param. Or a this or a that or a thing. Or a freakin partridge in a stupid pear tree >:-<

help again some more?

EDIT: I also tried doing it with

$UserCache->get_by_ID( $updated_pilot_id )

after correctly identifying the "updated_pilot_id" bit via params[User] but same thing: a group object that doesn't want to play nice with the few tiny little tricks I know.

4 Feb 07, 2009 07:18

echo $params['User']->Group->ID;

You'd have expected the group_ID to be correct though :-S

¥

5 Feb 07, 2009 13:16

Thanks again ¥åßßå. In my head I sort of thought "just keep guessing at combinations of ['these'] and ->those until you get lucky" but that gets frustrating fast ya know?

6 Feb 09, 2009 21:27

Okay something went weird after I went live with this thing. Seems that when I put someone else into a group then using $params['User']->Group->ID so that's what the code does.

		if( $params['User']->Group->ID != $old_pilot_data['pilot_group'] ) {
			if( $query_changed ) {$query .= ","; }
			$query .= " pilot_group = '".$params['User']->Group->ID."'";
			$query_changed = true;
			}

The problem now is that the very first registrant is actually officially in group #4, but for some reason my plugin's table thinks she is in group #0.

My GUESS is that I need to do something like this:

if( current_User is the same as User ) {
do something different 
} else {
do it the way ¥åßßå showed you
}

Thoughts? Oh and if any of you code junkies out there want to see the end result of all this lemme know and I'll PM you a register link. It's not much yet cuz all it does is collect a bunch of info with a post. I get a few days of rest before I have to start making it actually score points.

7 Feb 12, 2009 05:27

Okay this is (a) causing registration problems and (b) not worth trying to fix nicely. I'll just do a query I shouldn't need to do and get the new user's group ID for the "AfterUserUpdate" hook so that people can register.


Form is loading...