Pass User ID while calling insert_activity function for New  Media

For API development, user is not logged in, hence no user_id is inserted for activity. So need to pass it directly from $user variable.