News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Automated adding of users in smf_members table problem

Started by hiprakhar, February 28, 2011, 02:42:24 PM

Previous topic - Next topic

hiprakhar

Hello,

I am adding users automatically to SMF by adding records to smf_members table. This is working all good and users are able to login through the usernames and passwords.

However, through this method, the statistics on the website is not getting updated. On the homepage it says:

<x> Posts in <y> Topics by <__> Members. Latest Member:  <__>

Fields marked with read are not getting updated. They just display the users which are registered through the standard process.

How to update these field marked in red when automatically adding users in smf_members table?

Help!

Arantor

You're not supposed to manually add records, since not only are those fields not updated, neither are the stats in the info centre.

What you should really do is call registerMember, which is in Subs-Members.php if I remember right.

hiprakhar

Thanks Arantor for the reply!

I'll be grateful if you can elaborate a little on you method.

Thanks.

Arantor


hiprakhar

#4
I   have   made   a  standalone   php   app,   that   registers users   both   in   my   portal   and  in   the   smf forum   simultaneously by   directly   adding   tuples   in   smf_members   table.

The   problem  is   that  I   cannot directly  call   registerMember   function that   you   mentioned as   it   will   work   only   when accessed by smf files.   There   are  a lots   of   parameters  that  the   function  uses,  which   I   cannot supply through my  app.

Can you  point  out   the  important  lines in  registerMember function where  'the total   members  number  gets updated' and where  the 'latest   member  profile  is updated'

  That way  I will  update these 2  informations   right after   adding members.

Arantor

Not all the parameters used are required, only a bare minimum are actually needed (just like the registration form doesn't force much information being required)

But since you're quite clearly not going to do it the proper way, and have to extend it next time the schema changes, might as well finish the job that way.

All of the values you need to keep up to date are modified by updateSettings() as called by the registration functions, and that's another SMF function in Subs.php, only that one you REALLY should use, seeing that it not only modifies the table, it also deals with caching of the values, it's not just as simple as updating the row.

Specifically it requires the following rows in smf_settings to be updated, for 'variable' -> 'value' (the table is two columns, in a key/value pair arrangement)
variable 'latestMember' -> the id of the new member
variable 'latestRealName' -> the displayed name of the new member
variable 'totalMembers' -> the displayed number of members total

You will also need to update smf_log_activity if you want the number of registrations per day to be logged anywhere.

Advertisement: