PHP code example of develtio / wp-forms

1. Go to this page and download the library: Download develtio/wp-forms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

develtio / wp-forms example snippets


if ( class_exists( '\Develtio\WP\Forms\Modules\Forms\CreateForm' ) ) {
    $options = [ 
        'send_mail' => true, // enables / disables sending an email, enabled by default
        'send_confirm_mail' => true // enables / disables sending of confirmation email, disabled by default
    ];

    $instance = new \Develtio\WP\Forms\Modules\Forms\CreateForm('Sample Form', $options);
    
    $mail = $instance->mail;
    $mail->setFrom(['[email protected]' => 'Sample form']);
    $mail->setTo(['[email protected]']);
    $mail->setTitle('Mail title');
    $mail->setConfirmMailField('contact_email'); // optional, if we send a confirmation e-mail, enter the name of the field from which the e-mail address is to be retrieved


    $form = $instance->form; // Nette Forms Instance
    $form->addText('contact_name')->setHtmlAttribute('placeholder', __('Name', 'develtio'));
    $form->addEmail( 'contact_email' )->setHtmlAttribute( 'placeholder', __( 'E-mail' ) )->setRequired( true );    

    $instance->save(); // Generate a form and post type
}

    $instance->setSuccessTemplate('<p>Thank you for contacting us</p>');

    $options = [ 
        'send_mail' => true, // enables / disables sending an email, enabled by default
        'send_confirm_mail' => true // enables / disables sending of confirmation email, disabled by default
        'csv_export' => true,
        'csv_export_fields' => [
            'id' => 'ID',
            'date' => 'Created At',
            'form_name' => 'Name',
            'form_surname' => 'Surname',
            'form_email' => 'Email',
            'form_phone' => 'Phone',
            'form_specialization' => 'Specialization',
            'form_experience' => 'Experience',
            'form_description' => 'Description',
            'form_linkedin' => 'LinkedIn',
            'form_cv' => 'CV',
            'form_consent' => 'Consent'
        ]
    ];