4

I am using the organic groups module which adds a field with machine name: group_audience to the user entity which can be seen at:

/config/people/accounts/fields

Somehow after install some other modules, this field disappeared. I would like to add it back the field's machine name was simply group_audience instead of field_group_audience.

When I try and create a new field with the Drupal 7 interface builder it always prepends field_ to any field that is create. How can I create a field that does not have the field_ prefix?

2 Answers 2

3

The Organic Groups module has a nifty API method for this. You just need to do a:

og_create_field(OG_AUDIENCE_FIELD, 'user', 'user');

This first checks if the field exists and creates it if it doesn't, then checks if an instance of the field has been attached to the user entity and creates it if it doesn't.

You can check this answer out to understand where and how you can run this snippet from.

0
2

You can add fields without prefixes with drush field-create command or by using Remove field name prefix module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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