Add Fields to Field Group programatically I have used "Field Group" module and created some groups in backend. Now i want to programatically add a field to the group.  How can I do that.

I am using Hook_form_alter, I have noticed that every field has an 'und'attribute in which the field group it belongs to is listed, but if a create and 'und' array and add a field group name to it, it does not work.

How should I do it?
This is a bit old, but I wanted to do the same thing and couldn't find an answer on the web. I ended up figuring it out by myself.

Let's suppose you created a field group through the CMS interface with the name "group_product_fields". You added some fields to that group.

Now you have a new field being included in the form programatically via hook_form_alter. You want to add that field to "group_product_fields". Here is an example of what the field could be:

$form['new_product_field'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('New product field'),
  '#description' =&gt; t('Description for this new product field'),
);


All you need to do now is to add that new field to the field group. To do that add the line below to the hook_form_alter. It can be placed anywhere inside it.

$form['#group_children']['new_product_field'] = 'group_product_fields';


That's all. You may wish to adjust the field weight for it to be positioned as you want. But in the end this is really simple. :)