There's no function to do this in Jira.
With Scriptrunner or your own code (I'm not sure other marketplace scripting or automation apps can support this), you could catch "worklog created" events, work out what was logged and simply delete it. If you did that, I'd strongly recommend feeding back to the person who logged it that you've killed their time log off.
However, I would not do this - both the delete and your idea of blocking scream of a broken process which needs fixing
If someone genuinley is working on something outside the sprint, stopping them recording that means that you are losing the information on what they were doing.
People will adapt to that if they have to. Imagine someone like me who has to account for 40 hours a week. If you force me to log all my time on active sprint items, then your data is going to be instantly useless, because I'm going to be forced to lie my way through the week.
You should not try to impose stuff like this, all it does is render your planning and reporting utterly useless. Go back to your people and find out why they might log time on stuff outside the sprint. Is it genuine? What are they really logging? Why? Why are the items they are logging on not in the sprint if they need to be done before the things that are?
Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events