Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
2 + 5 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     

Re: force changing password after importing user ?
by mjoel on 2021/7/27 6:56:18

thanks geekwright, wish someday xoops will have this incorporated in the core
Re: force changing password after importing user ?
by geekwright on 2021/7/25 3:33:13

A quick and dirty solution would be to change this line:
le="color: #000000"><?php $user->setVar('pass', md5($liste[3]));

to:
le="color: #000000"><?php $user->setVar('pass', '');


The 'pass' column will not correspond to any possible password, so the only way to log in will be going through the forgot password logic to reset it.
force changing password after importing user ?
by mjoel on 2021/7/24 2:56:25

Hi i saw this script on github.. Quick and dirty XOOPS user import from csv file by geekwright
https://gist.github.com/geekwright/3cc71647bdfd035e609c3a045fc6db41

how do i force the user to change their password for first time login in XOOPS ?

<?php /** * modified from script by christian@frxoops.org * Import users from a csv file into xoops 2.5.8 * * Put this file and your users.cvs file in the root of your site * go to http://yoursite/import_users.php in your browser * click the button to rn the import * * Don't forget to DELETE it after you run it! */ /* Example users.csv file: Bill;Barra;bill.barra@yahoo.com;changeme Mark;Knopfler;mark@knopfler.com;changeme Jim;Morrison;jim.morrison@gmail.com;changeme Roger;Daltrey;roger@daltrey.com;changeme */ // assuming this is in the web root include 'mainfile.php'; // make sure we run as a POST transaction, so database operations do not need "force" if ($_SERVER['REQUEST_METHOD'] !== 'POST') { echo '<form action="" method="POST"><input type="submit" value="Click to import"></form>'; exit(); } $fichier = 'users.csv'; // data file as : first name(pseudo);last name;email;password // remove line break on last record /** @var XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); if (false === $memberHandler) die("Unable to create member handler"); $time = time(); // Open file for read if (file_exists($fichier)) $fp = fopen("$fichier", "r"); else{ // unknown file echo "File not found !Import stopped.n"; exit(); } echo '<pre>Begin file import '.$fichier."n"; // import line by line while (!feof($fp)) { $ligne = fgets($fp, 4096); if ('' === trim($ligne)) { continue; // blank line } $liste = explode(";", $ligne); // create array foreach ($liste as $index => $value) { $liste[$index] = trim($value); } /** @var XoopsUser $user */ $user = $memberHandler->createUser(); $user->setVar('uname', $liste[0]); $user->setVar('name', $liste[1]); $user->setVar('email', $liste[2]); $user->setVar('pass', md5($liste[3])); $user->setVar('user_regdate', $time); $user->setVar('user_level', 1); // activated $user->setVar('user_viewemail', 1); $user->setVar('user_avatar', 'avatars/blank.gif'); $uid = $memberHandler->insertUser($user); if (false === $uid) { echo sprintf("Failed to insert user %s n", $liste[0]); echo "Importation stoppée.n</pre>"; fclose($fp); exit(); } $memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $uid); echo sprintf("Record %d - %s addedn", $uid, $user->uname()); } echo "Import finished successfully.n</pre>"; fclose($fp);

Who's Online

113 user(s) are online (94 user(s) are browsing Support Forums)


Members: 0


Guests: 113


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits