You can choose to receive messages only from trusted contacts. Select ‘Messages’ from the drop-down menu next to your profile picture (or click on ‘Messages’ at the top of the page) then click on ‘Settings’. Change your preference to ‘Only receive messages from my contacts’.
If you have chosen to receive messages from your contacts only, you will need to add members as contacts before they can send you a message. To do this, under ‘Messages’, select ‘My contacts’ and use the ‘Add contact’ button.