Confusion About Dataset Name

I am trying to implement the Login/Member Profile update page and have not been successful in getting it to work properly. While the Login button DOES validate the member, change to Logout along with displaying the My Profile button, Clicking on My Profile does NOTHING?

Facts:

  1. I have a custom database called CVOA_Members that gets initially populated by a static User Input Form. This is working properly. When I select Manage Dataset it shows:

  1. I implemented the Member Profile pages following the article:
    https://support.wix.com/en/article/how-to-create-member-profile-pages-with-wix-code
    In doing so I duplicated my original page containing the User Input form an then made it a Dynamic Page for use with this article when the user clicks on My Profile after logging in.
    What is confusing is that if I select this new dynamic page and click on Manage Dataset it shows:


NOTICE the two different Dataset Names? Is this possibly why I cannot get the Member Profile button to do anything?


  1. Here is my Wix Code for the Membership Profile that is shown behind the Dynamic page update form, as described in the article:

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(“#button2”).label = “Logout”;
$w(“#button3”).show();
}
else {
$w(“#button2”).label = “Login”;
$w(“#button3”).hide();
}
} );

export function button2_click() {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button2”).label = “Login”;
$w(“#button3”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;

// prompt the user to log in  
wixUsers.promptLogin( {"mode": "login"} ) 
  .then( (user) => { 
    userId = user.id; 
    return user.getEmail(); 
  } ) 
  .then( (email) => { 
    // check if there is an item for the user in the collection 
    userEmail = email; 
    return wixData.query("CVOA_members") 
      .eq("_id", userId) 
      .find(); 
  } ) 
  .then( (results) => { 
    // if an item for the user is not found 
    if (results.items.length === 0) { 
      // create an item 
      const toInsert = { 
        "_id": userId, 
        "email": userEmail 
      }; 
      // add the item to the collection 
      wixData.insert("CVOA_members", toInsert) 
        .catch( (err) => { 
          console.log(err); 
        } ); 
    } 
    // update buttons accordingly 
    $w("#button2").label = "Logout"; 
    $w("#button3").show(); 
  } ) 
  .catch( (err) => { 
    console.log(err); 
  } ); 

}
}

export function button3_onclick() {
wixLocation.to(/CVOA-MemberProfile/${wixUsers.currentUser.id});
}

  1. If I select My Profile buttton in the header note that onClick name matches wix code

  1. Here is the info for the Dynamic Page that should be invoked by the My Profile button and the URL matches the last line of the Wix Code.

Can someone PLEASE tell me what I am missing. I have been fighting with this for over two weeks, multiple other posts, comments, upgraded to Premium plan to get VIP support then logged a support ticket and was told Wix Support does not handle wix code. Two days ago when Wix Code was release I tried again and was told that I must use this forum to get assistance.

Hi,
can you please share the URL for your site?

Liran.

Thanks. the URL is: https://jds-cvoa.wixsite.com/cvoa
JD

Hello JD,

First, the script attached to the profile button click event contains unnecessary whitespace after the page name. Make sure to remove it so it appears as follows:

export function button3_onclick() {
  wixLocation.to(`/CVOA_Members/${wixUsers.currentUser.id}`); 
}

Second, your dynamic page is missing the {Id} field.
Click ‘Add Field’ and select ID to add it to the URL. It should look like this:

Best regards,

Thanks Much. I made the changes:

Saved, Published, Viewed published site, Logged in, Clicked My Profile. Again NOTHING???

Hi,

Note that your code points to ‘CVOA_Members’ while the name of the dynamic page is ‘CVOA-MemberProfile’.

Thats correct and the basis for my question in the title of my post. Does the page supposed to connect to the Database Name, which is (CVOA_MEMBERS) or the Dynamic Page name. I think WIx created the name CVOA-MemberProfile when I converted the MemberProfile input form to a dynamic page.

I just now noticed that If I click on the My Profile link at top of page, then the button3_onclick in the developer panel that it points to the wix code for this membership update feature.

Andd, if you select the dynamic page and maximize the wix code at bottom it ALSO points to the Wix code, but the URL in the export function for button3 was different.

This is very confusing. After changing the wix code to use CVOA-MemberProfile when I saved, published, and tested. NOW when I click on my profile after logging in it DOES bring up the dynamic page. When I input all the form elements and hit submit, Nothing Happens. I do have Success and Failure messaged defined in the dynamic page settings but I got neither of these messages? Should the wix code on that page point to CVOA_Members?

I was going to check what the Submit Button does and get this?

I deleted the Button and re-created it. The form is working now! Just need to work out how to direct successful back to home page. Only option is Stay on this Page or A Link. Dont see where to direct to another page???

You can do it with code using ‘wixLoaction.to(’/home’)’ for example (see Ido’s answer regarding member page).

Liran.

Hi.
I am having the same problem. However, I figured when you refresh the page you will see that you are actually logged in and the buttons show the correct state they should be in. (i.e Login switches to Logout and Profile button goes from hidden to display mode.
I talked to many wix support people and no one has been able to help.
I followed the same exact code on this article but no luck
https://support.wix.com/en/article/how-to-build-your-own-members-area-using-code
Anyone experiencing the same or have been able to resolve?

Hi cwvega76
Were you able to fix this issue? I am still looking for help. Thank you.

Yakup, I ended up hiring Nayeli Gomez, the “Code Queen” to fix it. It was way back in December when I was just learning Wix.

Thanks for the response! She responded to me with a tutorial link. See if I can tackle it myself.