Drupal 7 Working role

PHP code

node_object_prepare($node);

$node->title = $account->profile_teacher_profile[‘field_name’][‘und’][0][‘value’];
$node->language = LANGUAGE_NONE;

$body_text = $account->profile_teacher_profile[‘field_teacherads’][‘und’][0][‘value’];
$node->body[$node->language][0][‘value’] = $body_text;
$node->body[$node->language][0][‘summary’] = text_summary($body_text);
$node->body[$node->language][0][‘format’] = ‘filtered_html’;

$status_val = intval($account->profile_teacher_profile[‘field_less_status’][‘und’][0][‘value’]);
$node->field_status[$node->language][0][‘value’] = $status_val;
$node->field_teachlang[$node->language][0][‘tid’] = $account->profile_teacher_profile[‘field_first_language’][‘und’][0][‘tid’];
$node->sell_price = $account->profile_teacher_profile[‘field_hourly_rate’][‘und’][0][‘value’];
$node->model = $account->profile_teacher_profile[‘field_name’][‘und’][0][‘value’].date(‘c’);

$node->uid = $account->uid;

$path = ‘content/programmatically_created_node_’ . date(‘YmdHis’);
$node->path = array(‘alias’ => $path);
node_save($node);
drupal_goto(‘node/’.$node->nid);

?>

Was this article helpful?

Related Articles