1
prophecy100
Just a little request this time!

Hello all

I have written a little php script that copies the users username and password out of xoops_users and into a table in another database.

What I need to do is run this script when ever a new user is created, any idea where I should call this or where I can copy the code to in an existing XOOPS page to make this happen?

Thanks all,

Jonathan

2
theprof
Re: Just a little request this time!
  • 2004/7/25 19:05

  • theprof

  • Quite a regular

  • Posts: 225

  • Since: 2004/7/14


Is there a module or script where you can export just user name and email addy?

3
prophecy100
Re: Just a little request this time!

Here is the script I wrote to do what I needed, you could modify it very easily to copy out any information you wanted.


<?php
//MySQL Main DB Connection & Selection
$conn_main=mysql_connect("dbhost1", "dbusername", "dbpassword");
mysql_select_db("dbname",$conn_main);

//MySQL Gallery DB Connection & Selection
$conn_gallery=mysql_connect("dbhost2", "dbusername", "dbpassword");
mysql_select_db("dbname",$conn_gallery);

//Delete from Gallery DB
$delete_sql="delete from gallery_users";
mysql_query ($delete_sql,$conn_gallery) or die (mysql_error());

//Select data from Main DB (Outer Loop)
$totalsql="select uid from xoops_users order by uid desc limit 1";
$totalquery=mysql_query($totalsql,$conn_main);
while ($totalrow = mysql_fetch_array ($totalquery)) {
$totalcount=$totalrow['uid'];
}

$loopcount1=1;

while ($loopcount1 <= $totalcount) {

$xoops_sql="select uid,uname,pass from xoops_users where uid=$loopcount1";
$select_sql=mysql_query($xoops_sql,$conn_main) or die (mysql_error());
while ($row1 = mysql_fetch_array ($select_sql)) {
$phpuname=$row1['uname'];
$phppass=$row1['pass'];
}

if(isset($phpuname)) {
$gallery_sql="insert into gallery_users values ('$phpuname','$phppass')";
$insert_sql=mysql_query($gallery_sql,$conn_gallery) or die (mysql_error());
$loopcount1=$loopcount1+1;
unset($phpuname);
unset($phppass);
}

else {
$loopcount1=$loopcount1+1;
}
}

//Close MySQL Connections
mysql_close($conn_main);
mysql_close($conn_gallery);
?>


Jonathan

4
davidl2
Re: Just a little request this time!
  • 2004/7/25 20:02

  • davidl2

  • XOOPS is my life!

  • Posts: 4843

  • Since: 2003/5/26


Would this be possible .... both a routine to export current user details to another XOOPS site (or to create data that could be imported) - and secondly to log details into another site as new users upon registration?

Ok - heres a break down of what I mean :)

- User registers on site a
- Details are added to site a as per ususal
- details are also added to site b, to create new user...
- XOOPS see's both as new users - awaiting confirmation as per usual....


5
prophecy100
Re: Just a little request this time!

Well, I've never posted anything that's sparked off this much of a conversation before...

I would imagine that if you can find out exactly what is inserted into the database when a new user is created then this would be quite easy to do.

Without wanting to sound selfish here, has anyone got the answer to my original question?

Perhaps we could achieve all three of these things together?

Thanks all

Jonathan

6
prophecy100
Re: Just a little request this time!

Anyone?

7
ackbarr
Re: Just a little request this time!

User creation occurs in both /register.php and in /modules/system/admin/users/main.php

To make it simple, I would recommend only worrying about users that register their own account (in /register.php)

** All code from XOOPS 2.0.7

in /register.php ~ line 205 - 210:
if (!$member_handler->insertUser($newuser)) {
            echo 
_US_REGISTERNG;
            include 
'footer.php';
            exit();
        }
        
$newid $newuser->getVar('uid')


By this point the user record has been added to the local XOOPS MySQL db. Your code should be after line 210 and before line 275 which looks like this:
} else {
        echo 
"<span style='color:#ff0000; font-weight:bold;'>$stop</span>";
        include 
'include/registerform.php';
        
$reg_form->display();
    }

The following variables are available:
Quote:

$uname - login name
$email - email
$pass - first password entry
$vpass - second password entry
$actkey - User Activation key
$newuser - xoopsUser object representing the newly added user
$newid - uid of newly created user



Login

Who's Online

175 user(s) are online (133 user(s) are browsing Support Forums)


Members: 0


Guests: 175


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits