Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //acf select on cf7
- //add shortcode to cf7
- function add_faculty_and_classes_options_to_cf7() {
- wpcf7_add_form_tag( array( 'faculty_select', 'faculty_select*'), 'faculty_options', array( 'name-attr' => true ) );
- }
- add_action( 'wpcf7_init', 'add_faculty_and_classes_options_to_cf7' );
- //define shortcode
- function faculty_options( $tag ) {
- $faculties = get_field('faculties', 'option', false);
- $faculties = explode("\n", $faculties);
- $faculties = array_map('trim', $faculties);
- $output = "<select name='faculty_select' id='faculty_select'><option selected disabled>בחר פקולטה</option>";
- if( is_array($faculties) ) {
- foreach( $faculties as $faculty ) {
- $output .= '<option value="' . $faculty . '">' . $faculty . '</option>';
- }
- }
- $output .= "</select>";
- return $output;
- }
- //in cf7 add in form/mail
- [faculty_select*]
- // acf recipinet
- //in cf7 form
- <div style="display:none">[email* recipient-mail id:recipient-mail]</div>
- //in cf7 mail tab "to"
- [recipient-mail]
- // in code
- <?php $postRecipientField = get_field('course_recipient'); ?>
- <?php if ($postRecipient) {
- $postRecipient = $postRecipientField;
- } else {
- $postRecipient = 'xtra4@student.co.il';
- } ?>
- <span style="display: none" id="acf-post-recipient"><?php echo $postRecipient ?></span>
- <script>
- jQuery(function ($) {
- $(document).ready(function(){
- $('#recipient-mail').val('<?php the_field('course_recipient'); ?>');
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement