示例#1
0
        $value = "http://{$value}";
    }
    if ($valuetype == 'tags') {
        $value = string_to_tag_array($value);
    }
    $input[$shortname] = $value;
}
// display name is handled separately
$name = strip_tags(get_input('name'));
if ($name) {
    if (elgg_strlen($name) > 50) {
        register_error(elgg_echo('user:name:fail'));
    } elseif ($owner->name != $name) {
        $owner->name = $name;
        $owner->save();
        if (!smf_updateMemberData($owner->username, array('real_name' => $name))) {
            register_error(elgg_echo('bbsname:save:fail') . elgg_echo('zhaohu:sorry'));
            elgg_log("ZHError failed to set BBS real name for user {$owner->guid}", "ERROR");
        }
    }
}
// go through custom fields
if (sizeof($input) > 0) {
    foreach ($input as $shortname => $value) {
        $options = array('guid' => $owner->guid, 'metadata_name' => $shortname, 'limit' => false);
        elgg_delete_metadata($options);
        if (!is_null($value) && $value !== '') {
            // only create metadata for non empty values (0 is allowed) to prevent metadata records with empty string values #4858
            if (isset($accesslevel[$shortname])) {
                $access_id = (int) $accesslevel[$shortname];
            } else {
示例#2
0
/**
 * Set a user's email address
 *
 * @return bool
 * @since 1.8.0
 * @access private
 */
function elgg_set_user_email()
{
    $email = get_input('email');
    $user_id = get_input('guid');
    if (!$user_id) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_entity($user_id);
    }
    if (!is_email_address($email)) {
        register_error(elgg_echo('email:save:fail'));
        return false;
    }
    if ($user) {
        if (strcmp($email, $user->email) != 0) {
            if (!get_user_by_email($email)) {
                if ($user->email != $email) {
                    $user->email = $email;
                    if ($user->save()) {
                        if (smf_updateMemberData($user->username, array('email_address' => $email))) {
                            system_message(elgg_echo('email:save:success'));
                        } else {
                            register_error(elgg_echo('bbsemail:save:fail') . elgg_echo('zhaohu:sorry'));
                            elgg_log("ZHError failed to set BBS email for user {$user->guid}", "ERROR");
                        }
                        return true;
                    } else {
                        register_error(elgg_echo('email:save:fail') . elgg_echo('zhaohu:sorry'));
                        elgg_log("ZHError failed to set email for user {$user->guid}", "ERROR");
                    }
                }
            } else {
                register_error(elgg_echo('registration:dupeemail'));
            }
        } else {
            // no change
            return null;
        }
    } else {
        register_error(elgg_echo('email:save:fail'));
    }
    return false;
}