inserting a members user name in the reference field when posting new listings

hi can anyone help?? is there a way to insert a logged in members user name into the reference field in a new listing automatically? I am fairly new to code and any help would be greatly appreciated!

Reference filed contains an _id and nothing else.
When you update this filed by code, you always have to insert the reference _id to this field.

In the content manger it automatically displays the primary field value corresponding to this _id (but it’s like an addition after query).
You cannot change the primary field in the system collections such as Members/PrivateMemebersData.

so the code i am using is as follows

import wixData from ‘wix-data’ ;
import currentmember from ‘wix-members’ ;
import wixLocation from ‘wix-location’ ;

let memberId , memberEmail ;

async function checkIfLoggedIn ( ){
const thismember = await currentmember
return thismember ? true : false ;

$w . onReady ( () => {
if ( wixWindow . rendering . env === “browser” ) {
checkIfLoggedIn (). then ( res => {
if ( res === true ) {
$w ( ‘#dropdown6’ ). label = “memberId” ;
$w ( ‘#dropdown6’ ). show ;

  }  **else**  { 
      $w ( '#dropdown6' ). label  =  "memberId" ; 
      $w ( '#dropdown6' ). hide ; 


async function checkIfLoggedIn (){
const loggedInMember = await memberId . getMember ();
memberId = loggedInMember . _id ;
return wixData . query ( “Members” )
. eq ( “_id” , memberId )
. find ()
. then (( results ) => {
if ( results . memberid . length === 0 ) {
const toInsert = {
“_id” : memberId ,

      **export async function**  button4_click ( event )  
      wixData . insertReference ( Listings , Members , thisObj , memberId ) 
      . **catch** ( ( err ) => { 
        console . log ( err ); 

i am trying to show the logged in users id in a drop down on a form then when the form is posted attach the members account details in the multi reference field in Listings database however i am new to code and cannot figure this out or get my head round the code and any assistance or correction would be great

I don’t think I understand form your description what you’re trying to?
Are you trying to display a list of members? Based on what?
Are you trying to display this list as first + last names/IDs/emails?
What data and fields are in your Members collection?
Is the members collection contains a field referring to the system ?Members/PrivateMembersData or to the Members/PublicMembersData ?

@jonatandor35 the dropdown contains the current logged in user name / nickname from public members data, which i am trying to add to the reference field in an item listing database when the member posts there item so i can link there public profile to the item automatically. currently i can do this manually or add the reference field for the members to the dropdown box which populates the reference field with the users account however the dropdown list shows all the members that have posted items and not the user logged in.

@jonatandor35 i have also tried adding signed in user filter to the connected dataset for the dropdown for the members reference but that doesn’t work either

@un33kgames I still don’t understand. Why are you using dropdown if you only want to select the current user. Dropdown is for a list of items not for a single option.

@jonatandor35 Was using dropdown to try and filter by logged-in user as I said I’m new to this and any advise would be appreciated