Je crois que c'est facile avec une adaption du lostpassword.php (pas tester).
Essayez avec une petite formulaire dans une custom block.
<form action="bienvenue.php" method="post">
E-mail : <input name="email" size="26" maxlength="60" type="text"> <input value="Envoyer le bienvenue et le mot de passe" type="submit">
</form>
Creez une bienvenue.php:
<?php
include "mainfile.php";
$email = isset($_GET['email']) ? trim($_GET['email']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : $email;
xoops_loadLanguage('user');
if ($email == '') {
redirect_header("user.php",2,_US_SORRYNOTFOUND);
exit();
}
$myts =& MyTextSanitizer::getInstance();
$member_handler =& xoops_gethandler('member');
$getuser =& $member_handler->getUsers(new Criteria('email', $myts->addSlashes($email)));
if (empty($getuser)) {
$msg = _US_SORRYNOTFOUND;
redirect_header("user.php",2,$msg);
exit();
} else {
$newpass = xoops_makepass();
$xoopsMailer =& xoops_getMailer();
$xoopsMailer->useMail();
$xoopsMailer->setTemplate("bienvenue.tpl");
$xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
$xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
$xoopsMailer->assign("SITEURL", XOOPS_URL."/");
$xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']);
$xoopsMailer->assign("NEWPWD", $newpass);
$xoopsMailer->setToUsers($getuser[0]);
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$xoopsMailer->setSubject(sprintf('Bienvenue au %s',XOOPS_URL));
if ( !$xoopsMailer->send() ) {
echo $xoopsMailer->getErrors();
}
// Next step: add the new password to the database
$sql = sprintf("UPDATE %s SET pass = '%s' WHERE uid = %u", $xoopsDB->prefix("users"), md5($newpass), $getuser[0]->getVar('uid'));
if ( !$xoopsDB->queryF($sql) ) {
include "header.php";
echo _US_MAILPWDNG;
include "footer.php";
exit();
}
redirect_header("user.php", 3, sprintf(_US_PWDMAILED,$getuser[0]->getVar("uname")), false);
exit();
}
?>
Copiez lostpass2.tpl vers bienvenue.tpl et adaptez le a votre besoin.