I need to make a One time use page that automatically deletes its self after it is accessed and all of the correct info is inputted. This is for onboarding new clients to their modx installs.
Yes you can delete a snippet.
Something like this should work: (untested)
$snippet = $modx->getObject('modSnippet', $snippet_id);
$snippet->remove();
So why do you want to delete a snippet and not a resource/page?
what would the code look like for deleting a template? Would it be āmodTemplateā or something like that? Also if I have a php file that was uploaded through sftp how would I call a system setting in that php file? Ive tried to use the $modx object but it doesnāt work.
Yes, āmodTemplateā is the class for the templates.
If you want to have access to $modx, you have to load MODX externally:
https://docs.modx.com/current/en/extending-modx/modx-class/loading-externally
The code is somewhat different if you are using MODX 3.
Also after deleting a snippet you probably have to clear the cache ($modx->cacheManager->refresh();
) or the snippet code will still exist in the cache.
Thank you!!!
Iām almost certain that you donāt really want to delete a snippet. If Iām understanding you, you want a page that the user canāt access more than once.
If you can give us some more details, like how the user gets to the page, and what the page is for (registration, for example), and whether multiple users will go through the process, we might be able to suggest a better solution.