# Getting "createMember(member)" to work

**URL:** <https://forum.wixstudio.com/t/getting-createmember-member-to-work/53771>\
**Category:** Ask the community\
**Tags:** wix-members-area, code, question, wix-studio\
**Created:** [November 13, 2023, 10:06am UTC](https://forum.wixstudio.com/t/getting-createmember-member-to-work/53771 "2023-11-13T10:06:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom\_a](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tom_a/32/90138_2.png) [@tom\_a](https://forum.wixstudio.com/u/tom_a)\
**Post date:** [November 13, 2023, 10:06am UTC](https://forum.wixstudio.com/t/getting-createmember-member-to-work/53771/1 "2023-11-13T10:06:06Z")

</div>

I’m trying to set up a way to create a new user from within the site. I don’t want them to have to logout, then log back in for it to be done.

I have found “[createMember](https://www.wix.com/velo/reference/wix-members-v2/members/createmember)” and I’m trying to implement it. However, it’s not working for me.

I’m getting this error message:

![image](https://us1.discourse-cdn.com/wix/original/3X/2/8/2810ea9d89581ef4351b1026024088309cd04887.png)

Is anyone able to point me in the right direction/show me the correct code I need to be using? This is my page code:

> export function button6\_click(event) {
> 
> let slug = $w(“#input2”).value;  
> let nickname = $w(“#input1”).value;
> 
> let member = {  
> contact: {  
> emails: [`${slug}@test.com`]  
> },  
> profile: {  
> nickname: nickname,  
> slug: slug  
> },  
> loginEmail: `${slug}@test.com`  
> }
> 
> console.log(`${slug}@test.com`);
> 
> createMember(member)
> 
> }
> 
> async function createMember(member) {
> 
> //const members = wixAuth.elevate(createMember.member);  
> try {  
> const result = await members.createMember(member);  
> return result;  
> } catch (error) {  
> console.error(error);  
> console.log(“threw an error”);  
> // Handle the error  
> }  
> }

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [November 13, 2023, 3:54pm UTC](https://forum.wixstudio.com/t/getting-createmember-member-to-work/53771/2 "2023-11-13T15:54:03Z")

</div>

> I’m trying to set up a way to create a new user from within the site. I don’t want them to have to logout, then log back in for it to be done.

Question: What for do you need this functionality? Who will use this function & why?  
Why for example an already registered and logged-in user (member) should create a further member-acoount?

Or is it you as ADMIN → who wants to create members from within your site (page) ?

Reading just this sentence…

> I’m trying to set up a way to create a new user from within the site.\<

I understand, that this function is wanted from the view of an ADMIN.

But reading the next sentence →

> I don’t want them to have to logout, then log back in for it to be done.

…confuses again.

So what is your exact goal? Please describe a bit more in detail and explain what for you need this?

Futher, pay attention, that working just on FRONTEND → you will face → RESCTRICTIONS (security-reason). As i can see, your code is a FRONT-END-CODE → that means you may not have the rights, you normaly would get/have on BACKEND.  
So instead of using FRONTEND-API → you may better try to generate a BACKEND-CODE.

There are only 2 APIS which would help you as of my knowledge…

1. Wix-Members-Backend-API
2. Wix-CRM-BackendAPI  
In this both APIs also APIs like LOGIN/LOGOUT (AUTHENTICATION) should be included, as i can remember.

---

<div class="post-metadata">

**Author:** ![tom\_a](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tom_a/32/90138_2.png) [@tom\_a](https://forum.wixstudio.com/u/tom_a)\
**Post date:** [November 20, 2023, 5:40am UTC](https://forum.wixstudio.com/t/getting-createmember-member-to-work/53771/3 "2023-11-20T05:40:20Z")

</div>

Hi @CODE-NINJA

Thanks for the message and further info. Sorry about the late reply.

I managed to get this working. I put it in the backend, but it also needed “[elevated permissions](https://www.wix.com/velo/reference/wix-auth/elevate)” to work.

The functionality is for agencies. I want them to have a master login, and then be able to add new accounts for each client they onboard. This way, they can see a list of accounts linked to the master account and switch between them easily.

Thanks again!
