Skip to Content Skip to Menu

Lowest and highest User ID numbers

13 years 3 weeks ago - 13 years 3 weeks ago #178008 by busterocaps
Lowest and highest User ID numbers was created by busterocaps
I would like to write a script that updates a particular custom field before a user list is generated. I already have the code to update the field when the users profile is viewed, but now I want to be able to add a cb userlist menu item that will, when selected, show the user a list with the fields updated. This removes the step of having to view the profile first to get the field updated. I'm assuming I need to register for an event trigger, which I did.
Code:
$_PLUGINS->registerFunction( 'onBeforeUsersListBuildQuery', 'updateUserFields');
My next step is to have the function that updates the fields. I need to have a For loop to index through all of the users. I was going to use the user id field to do this, like so:
Code:
for($i = LOWEST_USER_ID; $i <= HIGEST_USER_ID; $i++) { CODE FOR UPDATE GOES HERE }
Problem is, I don't know how to get the two variables, lowest and highest user id.

any help?
Last edit: 13 years 3 weeks ago by busterocaps.

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
13 years 3 weeks ago #178022 by nant
Replied by nant on topic Re: Lowest and highest User ID numbers
do a query sorted by userid ascending and take the first.
do a query sorted by userid descending and take the first.

you have your min and your max.

Please Log in or Create an account to join the conversation.

13 years 2 weeks ago #178152 by busterocaps
Replied by busterocaps on topic Re: Lowest and highest User ID numbers
Thanks for the reply. I guess I'll look around and see how to do that from inside php. Seems like there should be an easier way. :)

Please Log in or Create an account to join the conversation.

13 years 2 weeks ago #178258 by busterocaps
Replied by busterocaps on topic Re: Lowest and highest User ID numbers
Ok, So I got the userid range, but now I can't see how to update the field for each user. How do you use the userid to update a field of that userid? I saw your tut on establishing the cbUser object but that always returns the logged in user. I need to be able to do a for loop that updates a field based on the userid. for example:
Code:
for ($i = $userIDlow; $i <= $userIDhigh;$i++) { /*These two lines only return the logged in user, even though it should change the userID with each iteration*/ $myId = $_CB_framework->myId($i); $cbUser =& CBuser::getInstance( $myId ); $cbUser->cb_xboxlivestatus = "online"; //$cbUser->store(); doesn't do anything } }

Please Log in or Create an account to join the conversation.

13 years 2 weeks ago #178546 by busterocaps
Replied by busterocaps on topic Re: Lowest and highest User ID numbers
Any help on this?

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
13 years 2 weeks ago #178560 by nant

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum