Forum Replies Created
-
AuthorPosts
-
msaohiostate
MemberI apologize for the ambiguity.
This plugin is called Smart Forms, its a plugin that allows for more complex forms to be inserted in to WP. We are currently using this plugin to run our elections as a student organization. We are currently collecting applications which is working fine however in the near future we will be voting and we would like to restrict voting to a one time submission. I reached out to the developer and he adjusted to code to only allow one submission per WP user however since we use WP eMember for our database it does seem to be compatible. He advised us to alter the code according to your php shortcodes etc however that didn’t solve the issue. The current issue is that eMembers can still submit more than one submission.
Here is the code for to php files, the 1st is part of the original plugin that should connect to the current user database and the 2nd is the full code for the extension for one time submission validation.
1st:
private function InsertEntryData(){
$emember_auth = Emember_Auth::getInstance();
$user_id = $emember_auth->getUserInfo(‘user_name’);
$currentuser=$user_id;
global $wpdb;
$result= $wpdb->insert(SMART_FORMS_ENTRY,array(
‘form_id’=>$this->FormId,
‘user_id’=>$currentuser->ID,
‘date’=>date(‘Y-m-d H:i:s’),
‘data’=>$this->FormString,
‘ip’=>$_SERVER,
‘reference_id’=>$this->ReferenceId
));
if($result==false)
return false;
$this->EntryId=$wpdb->insert_id;
$this->FormEntryData[“_formid”]=$this->EntryId;
$this->InsertedValuesString[“_formid”]=$this->EntryId;
$result=$this->ParseAndInsertDetail($this->EntryId,$this->FormEntryData,$this->GetFormElementsDictionary());
return $result;
}
2nd:
<?php
/**
Plugin Name: One time submission
*/
add_filter(‘sf_before_saving_form’,’smart_forms_one_time_submission’);
function smart_forms_one_time_submission($preInsertEntry)
{
if ($preInsertEntry->FormId != 21)
{
return;
}
require_once SMART_FORMS_API;
$query = new SmartFormsQuery(21);
$emember_auth = Emember_Auth::getInstance();
$user_id = $emember_auth->getUserInfo(‘user_name’);
$query->AddCondition(‘_UserId’,’=’, $user_id);
$result = $query->GetResults();
if (count($result) > 0)
{
$preInsertEntry->ContinueInsertion = false;
$preInsertEntry->AddAction(new ShowMessageInsertEntryAction(“Sorry you can not submit this form again”));
}
}
If we need to proceed with custom coding we have no problem however if its a simple fix we appreciate the help.
msaohiostate
MemberStill not working unfortunately
msaohiostate
MemberDo you think you’d be able to alter it for me please. If tried several times but I still can’t seem to get it to work. What do I have to add to this code to make it work.
Thanks
-
AuthorPosts