e107help.org Q&A
0 like 0 dislike
I want to run 2 checks before an admin add's a new entry into a plugin database table.

The first check is to make sure the user via user_id doesn't already exsist on the plugin table.

If I can get the first one done, then doing the second check would be easy as well.


So In admin_config.php

Where it has public function beforeCreate($new_data,$old_data)

I have $user_id = $new_data['user_id'];
$sql = e107::getDb();

$check_user_id = $sql->count('service_records_sys', 'sr_id, user_id, clone_number', 'user_id = '.$user_id.'');

if($check_user_id > 0)


     $errMsg = "The Error Message";
   return $errMsg;




return $new_data;



however, it's not displaying an error message, but displays succestful message, with the new entry in the db.
e107 version e107v 2.30
in Plugins by (459 points) 17 37 50

1 Answer

0 like 0 dislike

You need to render error message directly there or use addError() message functionality (message handler)

and return false to not create record in database.

this:   return $errMsg;    is true in check, so record is created. 


by (2.0k points) 18 48 58
996 questions
1,389 answers
2,512 users