Programmatically creating missing content profiles with default values bypassing validation
$sql = "select u.uid, u.name from users u where u.uid not in (select n.uid from node n where n.type='profile')";
$result = db_query($sql);
while ($data = db_fetch_object($result))
{
$node = array();
$node['type'] = 'profile';
$node['name'] = 'Profile';
$node['status'] = 1;
$node['format'] = 0;
$node['comment'] = 0;
$node['promote'] = 0;
$node['sticky'] = 0;
$node['uid'] = $data->uid;
$node['title'] = $data->name;
$node = (object)$node;
$node->field_cck1[0]['value'] = 1000;
$node->field_cck2[0]['value'] = 100;
$node->created = time();
$node->validated = TRUE;
node_save($node);
}
$result = db_query($sql);
while ($data = db_fetch_object($result))
{
$node = array();
$node['type'] = 'profile';
$node['name'] = 'Profile';
$node['status'] = 1;
$node['format'] = 0;
$node['comment'] = 0;
$node['promote'] = 0;
$node['sticky'] = 0;
$node['uid'] = $data->uid;
$node['title'] = $data->name;
$node = (object)$node;
$node->field_cck1[0]['value'] = 1000;
$node->field_cck2[0]['value'] = 100;
$node->created = time();
$node->validated = TRUE;
node_save($node);
}
Comments
Post a Comment