An open API service indexing awesome lists of open source software.

https://github.com/lcharette/uf_userprofile

Custom user and group profile fields for UserFrosting
https://github.com/lcharette/uf_userprofile

userfrosting userfrosting-sprinkle

Last synced: about 1 month ago
JSON representation

Custom user and group profile fields for UserFrosting

Awesome Lists containing this project

README

        

# Custom User Profile Field Sprinkle for [UserFrosting 4](https://www.userfrosting.com)

[![Donate][kofi-badge]][kofi]
[![Latest Version][releases-badge]][releases]
[![UserFrosting Version][uf-version]][uf]
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Build][build-badge]][build]
[![Codecov][codecov-badge]][codecov]
[![StyleCI][styleci-badge]][styleci]

[kofi]: https://ko-fi.com/A7052ICP
[kofi-badge]: https://img.shields.io/badge/Donate-Buy%20Me%20a%20Coffee-blue.svg
[releases]: https://github.com/lcharette/UF_UserProfile/releases
[releases-badge]: https://img.shields.io/github/release/lcharette/UF_UserProfile.svg
[uf-version]: https://img.shields.io/badge/UserFrosting->=%204.3-brightgreen.svg
[uf]: https://github.com/userfrosting/UserFrosting
[build]: https://github.com/lcharette/UF_UserProfile/actions?query=workflow%3ABuild
[build-badge]: https://github.com/lcharette/UF_UserProfile/workflows/Build/badge.svg?branch=master
[codecov]: https://codecov.io/gh/lcharette/UF_UserProfile
[codecov-badge]: https://codecov.io/gh/lcharette/UF_UserProfile/branch/master/graph/badge.svg
[styleci]: https://styleci.io/repos/83981830
[styleci-badge]: https://styleci.io/repos/83981830/shield?branch=master&style=flat

This Sprinkle makes it easy to add any custom fields to the user or group model. Simply create a new schema in you own sprinkle and you're done. Your new profile fields will be automatically integrated in the default UserFrosting interface.

# Help and Contributing

If you need help using this sprinkle or found any bug, feels free to open an issue or submit a pull request. You can also find me on the [UserFrosting Chat](https://chat.userfrosting.com/) most of the time for direct support.

# Installation

Edit UserFrosting `app/sprinkles.json` file and add the following to the `require` list : `"lcharette/uf_userprofile": "^3.0.0"`. Also add `FormGenerator` and `UserProfile` to the `base` list. For example:

```json
{
"require": {
"lcharette/uf_userprofile": "^3.0.0"
},
"base": [
"core",
"account",
"admin",
"FormGenerator",
"UserProfile"
]
}
```

Run `composer update` then `php bakery bake` to install the sprinkle.

# Usage

To add a custom profile fields to any user, you simply add a [FormGenerator](https://github.com/lcharette/UF_FormGenerator) compliant schema containing the `form` key as well as the traditional [validation schema](https://learn.userfrosting.com/routes-and-controllers/client-input/validation). The rest is generated by this Sprinkle.

For example, you can add the following to a `schema/userProfile/myFields.json` file inside your sprinkle to add a `location`, `occupation` and `gender` user field. With the associated locale keys, that's all you have to do to add a new user field to your UserFrosting setup.
```json
{
"location" : {
"validators" : {
"length" : {
"label" : "LOCATION",
"min" : 1,
"max" : 255,
"message" : "VALIDATE.LENGTH_RANGE"
}
},
"form": {
"type": "text",
"label": "LOCATION",
"icon": "fa-globe"
}
},
"occupation" : {
"validators" : {
"length" : {
"label" : "OCCUPATION",
"min" : 1,
"max" : 255,
"message" : "VALIDATE.LENGTH_RANGE"
}
},
"form": {
"type": "textarea",
"label": "OCCUPATION",
"icon": "fa-briefcase"
}
},
"gender" : {
"validators" : {},
"form": {
"type": "select",
"label": "GENDER",
"icon": "fa-transgender",
"options" : {
"1" : "GENDER.MALE",
"2" : "GENDER.FEMALE",
"3" : "GENDER.NEUTRAL"
}
}
}
}
```

Note that the schema must be saved inside the `schema/userProfile/` directory of your sprinkle to be picked up automatically by the system. You might also want to run `php bakery clear-cache` command from the UserFrosting root since those fields are stored in cache for better performances.

You can also specify **groups** custom fields by saving any schema in the the `schema/groupProfile/` directory of your sprinkle.

## Screenshots

![Screenshot 1](/.github/screenshots/UF_UserProfile1.png?raw=true)
![Screenshot 1](/.github/screenshots/UF_UserProfile2.png?raw=true)

# License
By [Louis Charette](https://github.com/lcharette). Copyright (c) 2020, free to use in personal and commercial software as per the MIT license.