2

My block code is as follows:

mymodule_block_info() {
  $blocks = array();
  $blocks['my_contenttype_form_block'] = array(
    'info' => t('My CustomContentType Add Form'),
    'cache' => DRUPAL_CACHE_PER_PAGE,
  );
  return $blocks;
}

function mymodule_ui_block_view($block_name = '') {
  global $user;
  switch ($block_name) {
    case 'my_contenttype_form_block':
  module_load_include('inc', 'node', 'node.pages');
  // Create a node for the content type.
  $node = new stdClass();
  $node->uid = $user->uid;
  $node->name = (isset($user->name) ? $user->name : '');
  $node->type = 'my_contenttype';
  $node->language = LANGUAGE_NONE;

  $block = array(
    'subject' => t('Create New CustomContentType record'),
    'title' => t('Create New CustomContentType record'),
    'content' => drupal_get_form('my_contenttype_node_form', $node),
  );
    break;
  }

  return $block;
}

The "Groups audience" field is missing. It shows up in the standard add page (mysite.com/node/add/my_contenttype).

I've tried setting this programmatically via hook_form_alter, and also by setting the $form_state['values']['og_group_ref'][0], but nothing seems to work (although it makes sense that these approaches are failing when the field isn't even in the form.

Thanks in advance for the assist! Any thoughts as to why it's missing?

0

For the benefit of others, I realized the user was not a member of the child group they were trying to add content to. They were members of the parent, but that didn't allow them to add content to the child group in question, so permissions didn't propagate as expected. There is an OG subgroups module (https://drupal.org/project/og_subgroups) which is supposed to help with this, but I wasn't able to configure it correctly for some reason before realizing that this particular application required the user to be a member of the subgroup in order for them to actually post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.