How to add a calculated field to Members database AFTER successful login

I’m trying to add 2 calculated fields into Private Members’ Data collection. Both these fields depend upon system generated fields that are created by the system AFTER login registration. Hence, they can be created only after login has successfully occurred.

The fields are:

  1. A date which is set to 1 year ahead of Creation_Date (where creation date is a system generated field once user registration is completed). This is for automatic reminder when account is due for renewal.
  2. A yes/no field where admin can manually populate the same based on actions taken by the user. Ex. The user/member is dead and admin would like to explicitly flag it for some purpose.

Have you actually read up about the Wix Members app PrivateMembersData collection?
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

Permissions

The PrivateMembersData collection has the following permissions :

  • Read: Site member author

  • Create: None

  • Update: None

  • Delete: None

You cannot change the PrivateMembersData collection permissions.

To do something like that you will need to create a separate dataset, you can see a good example here for making a member profile and update profile pages.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Now obviously you do not have to keep the tutorial and all on it exactly the same as it is, you can swap and change it to suit whatever needs you want for it.

https://support.wix.com/en/article/corvid-tutorial-displaying-todays-date-with-code

To do the date for admin you can do something similar to this code for a full year with the one datepicker

$w.onReady(function () {

let today = new Date();

let startDate = new Date(today);
startDate.setDate(startDate.getDate() + 1); // Start Date +1 day from today //

let endDate = new Date(today);
endDate.setMonth(endDate.getFullYear() + 1); // End Date +1 full year from today //

// Set min & max dates //
$w("#datePicker1").minDate = startDate;
$w("#datePicker1").maxDate = endDate;
});
});

//Don't use getYear() as not work with years after 2000
 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear //

Or to call it from a dataset already like this.

$w.onReady(function () {
$w("#dataset1").onReady(() => {

// Retrieve min & max dates from dataset //
let startDate = $w("#dataset1").getCurrentItem().start;
let endDate = $w("#dataset1").getCurrentItem().end;

// Set min & max dates for datepickers //
$w("#datePicker1").minDate = startDate;
$w("#datePicker2").maxDate = endDate;
});

Or set it up with the two datepickers like this.

$w.onReady(function () {
 $w("#datePicker1").onChange((event) => {
     console.log(event.target.value);
     let newdate = new Date(event.target.value);
newdate.setDate(newdate.getFullYear() + 1);
     $w("#datePicker2").value = newdate;
     $w("#datePicker2").minDate = newdate;
​
 });
});

Plus you can always just use the dataset’s own field for created date and work from there if you are wanting to.

There is also this previous forum post that could be a good read for you too.
https://www.wix.com/corvid/forum/community-discussion/solved-formatting-date-back-to-database#targetText=If%20you%20simply%20need%20the,Date%22%20field%20in%20each%20collection.