how to automatically select entity reference field value from url when adding a node I have a content type "Students" which has an entity reference field "Course".

Course field shows a list of course nodes titles from a view. 

When adding a new student node, I need the course field to be automatically selected as per the URL value. 

I will pass the course ID in the URL like this.

/node/add/student/COURSEID


Any idea how to get this done ?
thanks
I think the easiest way would be to use hook_form_alter() and set a default value for the field. You can use arg() to get the course ID