How to giver permission to individual users to access (view, edit) only their own content?

Hello want to create multi step form for multiple users.
Each user will have the permission to submit multiple forms and then edit those forms from his/her account.

Each user can only have access to the forms submitted by him/her and not other users forms.
Is this possible with modx current admin panel?
Do i have to download an extra package?
Or do i have to do it by writing my own code?

Thanks in advance

1 Like

Hi @pistolas1991boom

First of all, welcome to the community!
By your nickname I assume that you speak portuguese :smiley:

Before going into detailed tips, are you using any kind of extra for the forms, like formit? or is this a fully customized form?

2 Likes

Hi, thanks for your quick response.
I’m from Cyprus. And i speak Greek/English.

No i do not use any extra yet. I was planning to use Formit, but i don’t know if it is possible to give access to users to view or edit their own forms after submitting them with formit.

I want to know your suggestions on this topic as soon as possible. Thanks again

1 Like

Do you want a form that they can copy and duplicate? Is this within the modx manager or are they common (front-end) users?

If they will be user resources then, like a personal profile, the data would be limited to only that user, but there are other ways perhaps

Formit is good, how do you want them to be able to edit, just fill in new info or something else? If you can provide more info on what you need we can help understand the best way.

BTW, a big thing with Modx is, the core doesn’t do all that many extra functions. Users and several other basic functions, but not too many. This keeps the core secure and stable.

So, you will generally use quite a few Extras. Login for front-end users is a common one, and more specialized ones too.

You can also do custom snippets anywhere on your page to provide dynamic or other output

Hi and thanks for your response.

In general i want users to be able to:
Create a new account and login.
Then the user can be able tou fill a form
and then be able to edit this form
and then be able to submit a new one (not duplicate),
and a new one…(Eventually he/she will be able to view/edit a list with all the submissions)

this is possible at fronted with formit and formit2db.
You will need a custom-table, where the submits are stored.

For listings of the users submits, you could use migxLoopCollection from MIGX - Extra

Hi bruno. OK but i want EACH USER to be able to view and edit all the forms submitted previously by him/her.

that’s easy. Just store the user-id of the currently logged in user to the db-item.
Then you can filter by that id, while the user is logged in.

Ok thanks bruno.
And what about the Editing of each listing, is there anything build in modx or i have to do it programmatically?

you can edit items with formit and the formit2db - hook and db2formit - prehook

So, i have installed formit and i was able to submit a form with a simple textfield. Then i have installed formit2db and the form wasnt sumbitting to the backend. Then i found out that the problem was created after installing formit2db. Then i uninstalled formit2db and the form was sumbitting the data properly. Do you know what am i doing wrong?

1 Like

not without seeing your code

1 Like

There you go. It works only with formit2db.
[[!FormIt? &hooks=FormItSaveForm]]

<h2>Contact Form</h2>

<form action="[[~[[*id]]]]" method="post" class="form">
    <input type="text" name="name" id="name" />
    <input type ="submit" value="Send Contact Inquiry" />
</form>
1 Like

It seems to me this is effectively a function like “my forms”. I don’t think this is too difficult.

So on the form you will probably need a posthook, to save the form in the format you want, with the user id of course. The form itself is just going to ship off the data by email or whatever, so any saving would be an additional function. Many ways to do this actually.

Then, you would need a snippet that would search that db for the user id, then output any files. The current user id will always be used, so they only see their docs

So, formit sumbissions table does not include user id from what i can see in the data structure.
I need to add the user id in formit and then use the posthook to save it

1 Like

Well, formit will save an html form I think, is that the format you want? I don’t know if you could re-purpose one of the fields related to users, maybe you could, otherwise you would probably need to make a custom database unfortunately.

My thinking is perhaps you could save this form as essentially an html form, you still want them to be able to change the form, right? That’s why I think keep it in html.

What functions do you want them to have? Downloader-R would help you let them download the file locally.

My thinking is, on the appropriate page, you just have a small snippet that searches the user table for the current user, and outputs the forms. This would still basically be in html, the forms could all output completely, or something like getImage could get the file list to output.

Pls tell us moreb about what you want the functions to be.

Bruno my code is based on your code. I have a custom table in db called modx_user_forms.
And i want to edit those forms. But nothing seems to works, plus when page loads im getting an error ( Failed to create object of type: )
You can see my progress below:

[[!FormIt? 
    &hooks=`formit2db` 
    &preHooks=`db2formit`
    &prefix=`modx_users_`
    &tablename=`forms`
]]

<p>[[+fi.error.error_message]]</p>
<form class="form" action="[[~[[*id]]]]" method="post">
    <input name="nospam" type="hidden" />
    <input name="resource_id" type="hidden" value="[[+fi.id]]" />
    <input id="userid" name="userid" type="text" value="[[+fi.userid]]" />    
    <input id="formid" name="formid" type="text" value="[[+fi.formid]]" />    
    <div class="form-buttons">
        <input type="submit" value="Save" />
    </div>
</form>
1 Like

The purpose of this table is to store user forms with the form id. Then i want to list and edit those forms for each individual user.

E.g User 1 logged in

form list for user 1 only:
Form 1 for user 1
Form 2 for user 1
Form 3 for user 1

1 Like

Let’s see your code to save the forms, they must be saved somewhere, maybe I am lost in what each extra does here

More code, pls, i am very lost in the sea of hooks and prehooks