I'm having trouble allowing web users to delete a resource they have created through a spin-off of eForm2db.
Just for testing purposes, I've got my basic snippets and chunks created for eForm to parse the input.
My snippet "DeleteBlogPost":
<?php
function DeleteBlogPost( &$fields )
{
global $modx;
$table = $modx->getFullTableName("site_content");
$id = $modx->db->escape($fields[id]);
if (is_int($id)) {
$rows_affected = $modx->db->delete($table, "id = $id");
}
return true;
}
return $html;
?>
My Chunk "eFormBlogDeleteTpl":
<form method="post" action="[~[*id*]~]" id="blogPostDelete" name="blogPostDelete">
<input name="formid" type="hidden" value="blogPostDelete" />
<label>ID:</label>
<input name="id" class="form" size="2" type="text" eform="::0::" />
<input type="submit" name="submit" value="Delete" />
</form>
My Chunk "eFormConfirmDelete":
<p>This resource has been deleted.</p>
My Snippet Call:
[!DeleteBlogPost?!]
[!eForm? &noemail=`true` &formid=`blogPostDelete` &eFormOnBeforeMailSent=`DeleteBlogPost` &tpl=`eFormBlogDeleteTpl` &thankyou=`eFormConfirmDelete`!]
When inputting a specific ID and submitting, I get a confirmation from the Thank You chunk, but the resource is not deleted.
My goal is to output a list of blogs a specific web user has created and give them the ability to update/delete their specific posts. Another concern here is redeclaring the function multiple times with ditto and working around that?
I'm not sure if this is the best approach. Any tips here?