• Hi,

    I’m trying to create a dynamic form using Contact Form 7. The form should populate custom meta fields of a custom post type (Job) to the front end. Since some of the fields are persisted in the database as arrays the number of fields differ from a job to another(Ex: Job Related Questions). After some research I decided to manually create a template containing the form and hook it to a WordPress page. I used Contact Form 7’s shortcodes to generate the input fields. I’m stuck at the last step which is storing the data in an admin-accessible storage (Ex: Flamingo). Is there a way to do that programatically?

    Here is my code

    <?php
    $job_id =  $_GET["job_id"];
    $job_post = get_post($job_id);
    ?>
    
    <div class="application-container">
    <h1 class="job-title-header"><?php echo get_the_title($job_post) . ' Job Application'; ?></h1>
    
    <form id="job-form" name="job-form" action="" autocomplete="off">
    		<section class="application-info-sec">
    		<h3>Personal Information</h3>
    			<div class="row">
    				<div class="col col-4">
    					<label for="first-name">First Name</label><br>
    					<?php echo wpcf7_do_shortcode('[text* first-name id:first-name placeholder "Ex: John"]'); ?>
    				</div>
    				<div class="col col-4">
    					<label for="middle-name">Middle Name</label><br>
    					<?php echo wpcf7_do_shortcode('[text* middle-name id:middle-name placeholder "Ex: John"]'); ?>
    				</div>
    				<div class="col col-4">
    					<label for="last-name">Last Name</label><br>
    					<?php echo wpcf7_do_shortcode('[text* last-name id:last-name placeholder "Ex: Doe"]'); ?>
    				</div>
    			</div>
    
    			<div class="row">
    				<div class="col col-4">
    					<label for="age">Age</label><br>
    					<?php echo wpcf7_do_shortcode('[number* age 40/40 id:age placeholder "21"]'); ?><br>
    				</div>
    				<div class="col col-4">
    					<label for="e-mail">Email</label><br>
    					<?php echo wpcf7_do_shortcode('[email* e-mail id:e-mail placeholder "Ex: [email protected]"]'); ?><br>
    				</div>
    				<div class="col col-4">
    					<label for="mobile-number">Mobile Number</label><br>
    					<?php echo wpcf7_do_shortcode('[tel* mobile-number id:mobile-number placeholder "Ex: 01234567890"]'); ?><br>
    				</div>
    			</div>
    
    			<div class="row">
    				<div class="col col-4">
    					<label for="address">Address</label><br>
    					<?php echo wpcf7_do_shortcode('[textarea* address rows:2 id:address placeholder "Ex: Egypt, Cairo, Downtown"]'); ?><br>
    				</div>
    				<div class="col col-4">
    					<label for="gender">Gender</label><br>
    					<?php echo wpcf7_do_shortcode('[select* gender id:gender "Male" "Female"]'); ?><br>
    				</div>
    				<div class="col col-4">
    					<label for="marital-status">Marital Status</label><br>
    					<?php echo wpcf7_do_shortcode('[select* marital-status id:marital-status "Single" "Married" "Divorced" "Widowed"]'); ?><br>
    				</div>
    			</div>
    
    		</section>
    
    		<section class="application-info-sec">
    			<h3>Upload Your Resume</h3>
    			<?php echo wpcf7_do_shortcode('[file resume id:resume filetypes:pdf]'); ?><br>
    		</section>
    
    		<section class="application-info-sec">
    			<h3>Job Related Questions</h3>
    			<?php $job_questions = get_post_meta($job_id, 'job_questions', true); ?>
    			<?php foreach ($job_questions as $question): ?>
    				<div class="row">
    					<div class="col col-12">
    			  		<label for="<?php echo $question ?>"><?php echo $question ?></label><br>
    						<?php echo wpcf7_do_shortcode('[textarea* ' . $question . ' id:' . $question . ' rows:4 cols:70]'); ?><br>
    					</div>
    				</div>
    			<?php endforeach; ?>
    		</section>
    
    		<section class="application-info-sec">
    			<input type="submit">
    			</input>
    		</section>
      </div>
    
    </form>

    Thanks in advance.

    • This topic was modified 4 years, 3 months ago by code4food.

    The page I need help with: [log in to see the link]

  • The topic ‘Contact Form 7 Dynamic Form Data Storage’ is closed to new replies.