Mentioned by Marcus,
You should create an entityreference field from the profile2
Please let me add a picture to explain this sentence in detail,
Using hook_profile2_presave instead of using Rules
- Make a node with Fivestar
- Add Nid into profile 2
function mymodule_profile2_presave($profile) {
// is_new is important becase we will add fivestar into mint profile2
if ($profile->is_new && ($profile->type == 'main')) {
global $user;
// Make node for Fivestar and comments
$node = new stdClass;
$node->type = 'profile_rate';
$node->title = 'Rating for the profile';
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
//TODO: Who should be the owner?
$node->uid = $user->uid;
// No promote to front
// Published node
$node->status = 1;
$node->promote = 0;
// Comments open
$node->comment = 2;
// Try to save node
$node = node_submit($node);
node_save($node);
// Save Fivestar NID into profile 2
$profile->field_article_ref[LANGUAGE_NONE][0] = array('target_id' => $node->nid);
}
}