Get user id by model primary key name

Get the user id by the primary key name defined in the User model, instead of assuming "id" as primary key.