get entry by id, get entry by key

Hi Steph. I am working within a ‘frm_validate_field_entry’ plugin. I have three basic and simple question, hope you can help me here.

1. Let’s say I know the ID of a previouslly submitted entry ($myid). How do I retrieve the full entry and put it in a array ($myarray)? something like:

$myarray = getmyentry($myid) ?

2. Same as above, but this time I have the entry KEY in $mykey.

3-. Is there a way to know if a $frm_entry->destroy( $myID ) was successful or not? it looks to me it always returns zero. maybe you can set it to return the number of deleted entries in the future?

Thanks!

1 & 2. You can get an entry with:
global $frm_entry;
$frm_entry->getOne($myid);
This accepts the key or ID.

3. Deleting entries returns the number of rows deleted. This is a WP function and is working correctly in my testing. What version of Formidable are you using?

Hi Steph.

I am using the latest stable version of Formidable pro.

$frm_entry->getOne($myid); works fine, however, strangely enough, it does not return the full entry but only some fields of it.

$frm_entry->destroy( $myID ) returns always "0" to me.

here's my test code:

<?php
/*
Plugin Name: FormExamRemove
Description: Cancella l'iscrizione da un esame
Version: 0.000000001
Author: Michele Capurso, As suggested by Stephanie Wells
*/
add_filter('frm_validate_field_entry', 'validate_delete_student', 20, 4);
function validate_delete_student($errors, $field, $value){

global $frm_entry_meta, $frm_entry;

// 233 è l'id del codice ID nel form di cancellazione
if((empty($errors)) and ($field->id == 233)){

echo "processo id";

$codID=trim($_POST['item_meta'][233]);

$studententry = $frm_entry->getOne($codID);

print_r($studententry);
 
Echo "<br ><br ><br ><big> La tua iscrizione e' stata regolarmente cancellata</big><br ><br >";

$risultato = $frm_entry->destroy($codID);

echo "risultato: $risultato";

}
return $errors;
}

?>

Use $frm_entry->getOne($myid, true);

This includes all the info from fields in the "meta" parameter.

If the destroy function is returning 0, it must not be deleting anything.

Topic closed.