Skip to content

Instantly share code, notes, and snippets.

@yanniboi
Last active December 27, 2015 03:59
Show Gist options
  • Save yanniboi/7263648 to your computer and use it in GitHub Desktop.
Save yanniboi/7263648 to your computer and use it in GitHub Desktop.
OG (Organic Groups) Snippets
<?php
$og_mem = og_membership_create($group_type, $gid, $entity_type, $etid, $field_name);
og_membership_save($og_mem);
dpm($og_mem);
og_membership_delete($og_mem->id);
<?php
$ref1 = entity_load_single('party_reference', array(524));
$ref2 = entity_load_single('party_reference', array(525));
$values = array();
$values['reference_party'] = $ref1->reference_party;
$values['type'] = $ref1->type;
$values['reference_referee_name'][LANGUAGE_NONE][0]['title'] = 'Mr';
$values['reference_referee_name'][LANGUAGE_NONE][0]['family'] = 'John';
$values['reference_referee_name'][LANGUAGE_NONE][0]['given'] = 'Doe';
$values['reference_referee_email'][LANGUAGE_NONE][0]['email'] = '[email protected]';
$ref3 = party_reference_create($values);
entity_save('party_reference', $ref3);
dpm($ref1);
dpm($ref2);
dpm($ref3);
$app = entity_load_single('flexiform_webform_submission', 53259);
$app->field_team_app_ref_church_leader['und'][0]['target_id'] = $ref3->reference_id;
entity_save('flexiform_webform_submission', $app);
dpm($app);
entity_delete('party_reference', $ref1->reference_id);
$app_id = 0;
$app = entity_load_single('flexiform_webform_submission', $app_id);
$app_wrapper = entity_metadata_wrapper('flexiform_webform_submission', $app);
$ref = $app_wrapper->field_team_app_ref_other->value();
$ref_wrapper = entity_metadata_wrapper('party_reference', $ref);
dpm($app);
dpm($ref);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment