Sunday, June 5, 2011

Drupal FBConnect

// Creating content profile programmatically bypassing validations

function hook_user($op, &$edit, &$user, $category = NULL)
{
global $user;

// Create a near empty content profile
if ($op == 'insert' && $edit['fb_avatar'] == 1)
{
$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'] = $edit['uid'];
$node['title'] = 'Facebook user - '.$edit['name'];

$node = (object)$node;

$node->field_aa[0]['value'] = 'asdf';
$node->field_bb[0]['value'] = 100;

$node->created = time();
$node->validated = TRUE;
node_save($node);
}

No comments:

Post a Comment