However, this will work only if you are integrating with Project with Time management in the projects settings.
If users are reporting directly to the task (by using the workplan) so this cannot be achieved. In PPM the only restriction for logging time into a task is when it is closed or complete and this will depend on the project settings configure for the specific project (setting After a task is complete, allow time to be logged)
The constraints you are adding will only display a message but will not prevent any action over the task. I mean the constraint violation will only be reflected in workplan page as one Schedule Warning.
The follwoing ER has been logged in order to include this fearure in the next PPM Version: QCCR1L45704