I am trying to use Display Suite (newest version) to format the profile page for users. I am using the Profile2 module and the default main-profile type. I have the user's full name (not username) split into the fields for first, middle, and last. I am trying to create a custom field to combine these three fields as the full name.

I am trying to create a code field but I don't know what variable or replacement pattern to use. There is nothing in the list of available tokens. I have tried php using $content and $entity and get undefined variable errors.

How can I create a custom field in Display Suite to combine these three fields from a Profile2 entity?

  • Have you used token In code field?
    – Rupesh
    Commented Jun 13, 2015 at 14:13

1 Answer 1


Enough trial and error and I finally figured it out. I ended up using Display Suite Code as the text format, but writing php code in the field code box.

And to grab the first name the code was: $entity->field_first_name['und'][0]['safe_value'].

  • Great that you found a solution. You can accept your own answer so that others looking for the same solution can see quickly that there is a likely working solution. Another approach might be to research applying computed_field module perhaps along with field_token_value that uses tokens (for providing other fields as variables) I haven't tried my suggestion, but thought I'd share as it looks worth exploring. These modules also have Drupal 8 versions as well as for 7. Commented Jul 17, 2018 at 14:58

Your Answer

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

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