terminal – How do I run a sudo command at login/logout on macOS

I’m trying to run a command at login/logout which requires sudo. I’ve read about LaunchDaemon and LaunchAgent but as I understand it, LaunchDaemon will run the command at startup with root permissions, and LaunchAgent will run it at login but with the current user permissions, which won’t always be an administrator.

Alternatively, is there a way to run my command without the need of sudo? I’m trying to wipe all files in the home directories (Desktop, Documents etc.) on user login/logout so am currently using sudo rm -rf /users/randomuser/Desktop/* etc. Similar to how a guest account works, but without the account being guest and with a little more control. I’m pretty new to this kind of thing so please explain like I’m 5. More than happy to try out another solution if required. Thanks!