Sharing Attributes Across Multiple Profiles

Last edit:  Jan 17, 2019

Contributors:  diana-lakatos lemingos

This guide will help you share attributes across multiple user profiles.
If your profiles happen to have the same Properties, you can extract them to a container profile which will group them and could be used in different profiles.

Requirements

To follow the steps in this tutorial, you should be familiar with users and user profiles. This guide builds on previous tutorials in the Get Started: Users section.

Steps

Sharing attributes across multiple user profiles is a three-step process:

Step 1: Create profile template

Create a general employee template. You can define other profiles that will have fields from the employee profile and some more.

marketplace_builder/user_profile_types/employee.yml

name: employee
properties:
  - name: name
    type: string
  - name: email
    type: string
  - name: emergency_contact
    type: string

Step 2: Create profiles

marketplace_builder/user_profile_types/software_developer.yml

name: software_developer
properties:
  - name: programming_languages
    type: array

marketplace_builder/user_profile_types/project_manager.yml

name: project_manager
properties:
  - name: projects_managed
    type: array

Step 3: Use profiles

An example of using the software developer profile on a sign-up form:

marketplace_builder/form_configurations/software_developer_signup.liquid

---
name: software_developer_signup
return_to: /software-developer/sign-in
resource: User
fields:
  profiles:
    validation: { presence: true }
    employee:
      validation: { presence: true }
      properties:
        validation: { presence: true }
        name: { validation: { presence: true } }
        email: { validation: { presence: true } }
        emergency_contact: { validation: { presence: true } }
    software_developer:
      validation: { presence: true }
      properties:
        validation: { presence: true }
        programming_languages:  { validation: { presence: true } }
---
[...]

An example of using the project manager profile on a sign-up form:

marketplace_builder/form_configurations/project_manager_signup.liquid

---
name: project_manager_signup
return_to: /project-manager/sign-in
resource: User
fields:
  profiles:
    validation: { presence: true }
    employee:
      validation: { presence: true }
      properties:
        validation: { presence: true }
        name: { validation: { presence: true } }
        email: { validation: { presence: true } }
        emergency_contact: { validation: { presence: true } }
    project_manager:
      validation: { presence: true }
      properties:
        validation: { presence: true }
        projects:  { validation: { presence: true } }
---
[...]


Next steps

Congratulations! You know how to share attributes across user profiles. You can learn more about Form Configurations here:

Questions?

We are always happy to help with any questions you may have. Check out our Help page, or contact us.