:::

10-1 新增XOOPS會員

function add_user_to_xoops($name = "", $uname = "", $id = "", $passwd = "", $email = "", $groupid = "")
{
    global $xoopsConfig;

    define('XOOPS_XMLRPC', 1);
    $_SERVER['REQUEST_METHOD'] = 'POST';

    $member_handler = xoops_gethandler('member');

    $email = empty($email) ? "{$uname}@{$_SERVER['HTTP_HOST']}" : $email;

    $newuser = $member_handler->createUser();
    $newuser->setVar('loginname', $id);
    $newuser->setVar('uname', $uname);
    $newuser->setVar('name', $name);
    $newuser->setVar('email', $email);
    $newuser->setVar('pass', md5($passwd));
    $newuser->setVar('user_avatar', 'blank.gif');
    $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8);
    $newuser->setVar('actkey', $actkey);
    $newuser->setVar('user_regdate', time());
    $newuser->setVar('uorder', $xoopsConfig['com_order']);
    $newuser->setVar('umode', $xoopsConfig['com_mode']);
    $newuser->setVar('level', 1);
    $newuser->setVar('theme', $xoopsConfig['theme_set']);
    $newuser->setVar('timezone_offset', "8.0");

    if (!$member_handler->insertUser($newuser, true)) {
        redirect_header($_SERVER['PHP_SELF'], 10, "無法新增XOOPS帳號");
    }
    $new_uid = $newuser->uid();
    if ($groupid == XOOPS_GROUP_USERS) {
        if (!$member_handler->addUserToGroup(XOOPS_GROUP_USERS, $new_uid)) {
            redirect_header($_SERVER['PHP_SELF'], 10, "無法加入群組");
        }
    } else {
        if (!$member_handler->addUserToGroup(XOOPS_GROUP_USERS, $new_uid) or !$member_handler->addUserToGroup($groupid, $new_uid)) {
            redirect_header($_SERVER['PHP_SELF'], 10, "無法加入指定群組");
        }
    }

    return $new_uid;
}

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1845%26tbsn%3D48

書籍目錄

展開 | 闔起

線上使用者

36人線上 (8人在瀏覽線上書籍)

會員: 0

訪客: 36

更多…