From here modifying the app/booking/new screen so that will users will no longer be selecting themselves from a dropdown list is a relatively straightforward task.
Edit the app/views/booking/new.phtml or new.volt file. Remove the the form-group which includes the label and field/dropdown for the memberid as highlighted below.
We no longer need to capture this data from the user for the booking as we can retrieve it from the session login data.
Next edit the Booking controller which gathers this data from the booking/new form. Go to the createAction() function and find the line which get's the memberID from the form as follows.
Replace this line with the following line
Because we stored an object with the logged in user's details in a session variable called user when we call $this->session->get('user') this evaluates to be a User object. We can then call getters and setters on this object. In addition we can call the getMember() magic method on the object which will return the related Member object for that user using the hasOne relationship defined in the initialize function of the User class. This retrieves the associated Member object and we can call getters and setter from the Member class on it.
We probably need to make sure that it is not possible to arrive at the booking screen unless the User is logged in - otherwise this code will error. To prevent this we could wrap our line of code in a check to see if the user is logged in, otherwise send an error message an re-route to the login screen.
Don't forget to make this work we have to make sure to relate the user to an existing member by including the foreign key in the related record. In the following database tables I have related userid number 1 to member 11.
Now when I create a booking no dropdown appears for the memberid
Nevertheless the booking is created for Member number 11 - Joe Bloggs because I logged in as User number 1 Joe Bloggs.