Usually, an id is assigned to a row only at the moment it is inserted into the database. It does not exist before this moment. After it, it is already insert, and nobody else will be able to insert another row with the same id (assuming it is a uniquely indexed column).
So, your example seems to be invalid. Anyway, the question still makes sense if we ignore the example and consider the opening phrase: "I need to temporarily protect custom rows of a table from editing by another users."
In this case, you need to store somewhere the value of the IDs being edited, and by which user. Then, you need to check this data to allow / disallow an edit action.
In fact, the main problem here is the UNLOCK phase, due to the stateless nature of web/HTTP applications. If the row is not properly UNLOCKED after its edition or some kind of timeout, it will be permanently locked (instead of temporarily).