Reply To: Populate dropdown

Home Forums Quform WordPress Populate dropdown Reply To: Populate dropdown

#29667

Icemanmx
Participant

Ok
One more thing i forgot about..
Now when i have the code in the database, how can i read it from database and validate that the code excist before sending the form data.


function encuesta_notification_content( PHPMailer $mailer, Quform_Notification $notification, Quform_Form $form ) {
	ob_start();
	include __DIR__ . '/encuesta-post-evento.php';
	$mailer->Body = ob_get_clean();
}
add_filter( 'quform_pre_send_notification_1_1', 'encuesta_notification_content', 10, 3 );

add_filter( 'quform_element_valid_1_37', function ( $valid, $value, $element ) {

	//$pathcheck = WP_PLUGIN_DIR . '/surveyhdapg/codes.txt'; // This just checking the path to the wp-plugin folder.
	//echo '<script language="javascript">';
	//echo 'alert("Path:' . $pathcheck . '")'; 
	//echo '</script>';

	$codes = file( WP_PLUGIN_DIR . '/surveyhdapg/codes.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );

	if ( !in_array( $value, $codes ) ) {
		$element->addError( 'Código no válido' );
		$valid = false;
	}
	return $valid;
}, 10, 3 );

I hope i explained it okay…
Best Regards
Icemanmx

  • This reply was modified 3 months ago by  Icemanmx.
Be inspired. © 2019 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy