Assign record to specific user

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 6, 2022   (RSS)

Hi

I would like to let the administrator of a CMSB database, to be able to assign a record from one section to one or more users (chosen from the list of users). This way, when each user is logged in with his personal username/password and opens this section, he/she will be able to see and edit the record(s) that the administrator has assigned for him/her. 

Any ideas on how to do it?

Kind regards,

Andreas Lazaris

By daniel - January 4, 2022

Hi Andreas,

If you're working within the CMSB admin, a functionality close to what you describe is available by default - when editing a record it should show a line at the top that starts with "Created" which lists when the record was created, and who it was created by. Clicking "change" lets you change the creator of that record. A user whose permissions are set to "Author" for a section can only see and modify records that they have created.

The main limitation here is that this cannot be used to assign a record to more than one user.

If being able to assign multiple users is a necessity, that gets into some more complex functionality and depends somewhat on your current user setup. If you can provide some further details, I can describe some options for how to achieve this:

  • Are the users logging into the CMSB admin, or are they logging into front-end pages?
  • Are you using the Website Membership plugin? 
    • If yes, what is the "WSM_ACCOUNTS_TABLE" option set to in the plugin?

Thanks,

Daniel
Technical Lead
interactivetools.com

By daniel - January 6, 2022 - edited: January 6, 2022

Hi Andreas,

Something like this should be possible, but it will require some custom programming. I would do something along these lines:

  1. Create a multi-select field to the section that points at the accounts table, so you can select multiple users
  2. For users that you want to have the limited access to the section assign the "Author" permission
  3. Set up a custom plugin that uses the "record_access_where" filter to add a filtering condition for that section, checking to see if the currently logged in user has been assigned to the new field.

This is a bit too involved for me to fully detail on the forum, but if you have any specific questions about these steps I'll do my best to answer! Or if you'd like some hands-on assistance we're always happy to provide an estimate for the work: https://www.interactivetools.com/estimate/

Thanks,

Daniel
Technical Lead
interactivetools.com