Hi everybody,
Is it possible to have a user, prior to him or her requesting site membership, enter data in a form linked to a non-member collection (set to “anyone” form submission - form “A”) and then, once he has signed up as a member via a separate process (customized membership request form “B”), call up the previously generated form-“A”-based data in his private member area, so this user-now-a-member can update (as a member-author) this data?
Any guidance on how to call up data from separate, non-member data collections in member areas with “read & write” permission restricted to a specific user?
Envisaged steps:
-
An occasional site visitor is interested in getting in touch; for this he needs to fill in a user form A available to everybody; data is collected in a form submission collection X
-
Afterwards, this user decides to sign up as a member via a customized Wix membership form B, his sign-up information being collected in Members/privateMembersData
-
This user now wants to have the information he previously provided via form A and kept in X, in order to update it, when needed, in his private member area
Hi 
I’m not sure if I understood what you’re trying do well, do you want the visitors on your site to sign up on a custom form and then edit their provided details in the member area when they sign up?
If yes, then you can use the register( ) function to sign them up on the custom form immediately - instead of providing their details on a form then signing up on the default form - Then you can create a member-area page where each member can edit their custom-provided data.
If you need help while doing these steps feel free to tag me in a post and I’ll try to help as much as I can.
Ahmad
Thanks a lot, @ahmadnasriya .
Yes - that’s the objective. Registration approval is set to manual. Pre-requirement for a user signing up is a complete set of address data … where CRM and contactInfo comes into play. Which does not offer access to the required data fields that on the other hand (if one uses a csv-data export, this is visible) are set up in the required way. Wix just does not allow to properly write into this. Next to creating a mess in the CRM, when collecting IP addresses as “user addresses”, when users are, e.g., abroad. As an example: I provided a tester profile to Wix Support - and after them using it, got 5 “addresses” in the CRM with no other info than “US”, “Guatemala”, “Ireland” and “Israel” and “Ukraine” - which happened to be the locations of Wix people involved in my support request. We just do NOT want to expose our clients to such a mess - next to not wanting to have any type of discussion with people asking for the info they see in their privateMember profiles, that Wix collects and stores.
The problem with the register function (the way I tried it) is that via “Options” address data can only be pushed into that CRM-contactInfo object that is not accessible anymore via queries (beyond SDK backend getUser procedures, if I understood well).
Or is it possible to use the register function to push data into other data collections kept separately via “Options” or else, that are than attached to the member-ID?
@ahmadnasriya : have a look at https://jochenimhoff.wixsite.com/test-bwi/registrierung (sorry, you might need to use browser-based translation). The process we envisage is to 1) get required user data an store it separately, and then 2) use the standard Wix sign-up process. Afterwards, the now-customer (member) should be able to keep his address data updated via his privateMember area.
If you want, fire a request with some phantasy mail account. Just fill in the fields in a dummy way (only mail and confim mail fields required formating) and fire “Bestätigen”. This will lead you to the registration lightbox.
I think that I get what you want.
Yes you can still save the details to another collection, and register users on the same form, you just need to register the user, get his/her ID and insert() the details in a collection that has a reference field to the members collection.
@ahmadnasriya : THANKS! Does that mean that for security reason I have to clone data from the initial “anybody”-form submission collection to another “read & write” one, before making it available to the relevant member? Should I do the “insert()” procedure via a backend function?
There are no security risks in this procedure, you can insert on the Backend as well as the Frontend , the result is the same, you only need to insert the fields that are not editable or not available in the built-in members collection, but you can also insert all the details as well, the choice is yours.
@ahmadnasriya In fact, that’s what I tried to do. I included a members collection ref field in my address data collection, and only passed email, lastName & firstName to the registration form. The issue I was missing was how to insert() the user ID into that collection. That’s why data shown in the members’ area were not those that should have been … it just referred to the first user in the collection. I tried with querying, filtering … but the missing link was the insert() part.
Is there a way to get the userID via a “beforeSave” procedure on the Wix registration form?
I’ll try - I hope you don’t mind if I come back to you, if I mess it up … 
That’s because you’ve inserted the data before registering the user, you need to register the user then get its ID and insert it as the value of the _owner field.
wixUsers.register(email, password).then(async(result) => {
let user = result.user;
let details = {
_owner: user.id,
name: // name text field,
email: // email text field
}
await wixData.insert('customMembersCollection', details)
})
Cool. Thanks, @ahmadnasriya ! Great to have guys like you around, helping the bloody beginners, like me. 
You’re welcome
I’m always glad to help
1 Like
@Ahmad
I deleted the previous post, as the code is already outdated. Hope, you don’t mind.
I managed in the meantime to solve the code in the backend, so that a registered member can insert a second member identity (then the _owner info is properly updated in my custom collection), but I still do not get the post-registration member ID that I could use to update the collection in case a user is not logged in / fully new. I just always get the same pre-request ID string …
The backend code looks like this - I call it “on click” (on viewport leave did not work either) in the lightbox (customized Wix registration form). But apparently, it’s still too early to catch the member-ID. If I did not have to use those lightforms (requested in the settings), I just would put a success message in-between, but here, I am a bit lost, to be honest. Please have a look (backend .jsw):
export async function sync (collection) {
let options = {
"suppressAuth": true,
"suppressHooks": true};
let user = wixUsers.currentUser
let details = {
_owner: user.id}
await wixData.update(collection, details,options)
}
I tried you approach, by the way, but it did not work either in the frontend. It just produced errors and duplicated data entries. In the backend, error messages disappeared, but the the result was still the same. This just as a sign, that I did not ignore your advice, @Ahmad.
Please note that when updating an item, the update process will replace the item being updated with the new item, so replacing an item with one field like yours will erase the fields in the item with one field.
For example, if user is an object:
let user = {
_id: sdfdfsdfisdf,
name: User,
email: email@example.com
}
When updating the name, the object will become:
user.name = 'new name';
wixData.update('collection', user).then((result)=> {
result = {
name = 'new name'
}
})
The right way to update is getting the whole item and assign the field with a new item then update the whole item, like this:
let user = {
_id: sdfdfsdfisdf,
name: User,
email: email@example.com
}
user.email = newEmail@example.com
wixData.update('collection', user).then((result) => {
console.log(result)
})
/* result = {
_id: sdfdfsdfisdf,
name: User,
email: newEmail@example.com
}*/
Also, the members collection can’t be edited or updated this way, you need to use the updateUserFields() on the Backend.
1 Like
Everything works … BUT NOT IN LIVE MODE … I got the timing right in case, an existing, logged-in user registers a second identity (preview mode), but still don’t get ANY owner ID in case a new customer (not logged in) registers (live mode). I just don’t get it - there is no owner ID.
Let’s see:
- I register the contact in my own address collection on _click - no owner ID data entry yet. Fine - address is properly recorded.
- I open a lightbox, with a register() command. On “register” button click I in fact do not close the lightbox yet, but show a second “thank you” message with a button. Fine - registration request recorded. Member status is pending, awaiting manual approval. All ok.
- I let the user close the lightbox then with a second “close” button that fires a function to update the _owner field with the user.id in the backend. THIS ONLY WORKS IN PREVIEW MODE.
Here is the code for the last part - could you please check?
export function sync (collection,eMail) {
let options = {
"suppressAuth": true,
"suppressHooks": true};
let user = wixUsers.currentUser
wixData.query(collection)
.eq("eMail", eMail)
.find()
.then( (results) => {
if(results.items.length > 0) {
let hit = results.items[0];
hit._owner = user.id,
wixData.update(collection,hit,options)
}
} )
.catch( (err) => {
let errorMsg = err;
} );
}
Browser console message, probably (?? difficult to tell, given the codification of the bolt-worker.js) linked to the query not finding anything:
e. @ ua-parser.js:1
3bolt-worker.js:1 Uncaught (in promise)
Any idea where to look at still?
Or better to alternatively update the record at first user log in after approval? If yes, do you have any code snippet readily at hand, eventually, so that this update is only done once?
You can only inset a custom _owner value when inserting new entries into the database, once the entry is registered, you cannot edit the _id and the _owner fields.
When inserting while logged in, the _owner field is assigned with the current logged in user ID as the field value, so, as I suggested before, register the user, get his ID, then insert into a new collection.
Please note:
Wix Users module doesn’t work on the Backend , you need to import wixUsersBackend module.
import wixUsersBackend from 'wix-users-backend';
Also, the option object you’ve defined is not being passed as a parameter for the find() function, therefore, if user doesn’t have permissions, the promise will be rejected.
Thanks, Ahmad. So I need to revert my steps. First register, then record addresses.
re backend - oops. Thanks!