[Plugin: Contact Form 7] $cf7->posted_data & checkbox fields
-
Hi,
I’m having trouble accessing checkbox field data using the $cf7->posted_data functionality.
I have a form:
<p><b>Contact Name</b> (Required)<br /><br /> [text* contact-name 75/] </p> <p><b>Contact Email</b> (Required)<br /><br /> [email* contact-email 75/] </p> <p><b>Article Title</b> (Required)<br /><br /> [text* article-title 75/] </p> <p><b>Article Content</b> (Required)<br /><br /> [textarea* article-content 76x20] </p> <p><b>Modality</b> (Required)<br /><br /> [checkbox* article-modality use_label_element "Acupressure" "Acupuncture" "Alexander Technique" "Aromatherapy" "Art Therapy" "Ayurvedic" "Biofeedback" "Body/Mind Therapy" "Bowen Therapy" "Brain Gym" "Breathwork Therapy" "Chinese Medicine" "Chiropractic Therapy" "Colonics" "Colour Therapy" "Counselling" "Craniosacral Therapy" "Crystal Therapy" "Cupping Therapy" "Dietitian" "Ear Candling" "EFT (Emotional Freedom Technique)" "EMF (Electromagnetic Field Therapy)" "Energy Healing" "Feldenkrais" "Feng Shui" "Flower Essence Therapy" "Gestalt Therapy" "Herbal Medicine" "Holistic Pulsing" "Homeopathy" "Hypnotherapy" "Iridology" "Kinesiology" "Laser Therapy" "Life Coaching" "Lymphatic Drainage" "Macrobiotics" "Magnetic Therapy" "Massage – Chinese" "Massage – Corporate / Workplace" "Massage – Deep Tissue" "Massage – Holistic" "Massage – Infant" "Massage – Pregnancy" "Massage – Remedial" "Massage – Shiatsu" "Massage – Sports" "Massage – Stone Therapy" "Massage – Swedish / Relaxation" "Massage – Thai" "Massage – Therapeutic" "Meditation" "Music Therapy" "Myofascial Release Therapy" "Naturopathy" "Neuromuscular Therapy" "NLP (Neuro-Linguistic Programming)" "Numerology" "Nutrition" "Osteopathy" "Oxygen Therapy" "Personal Training" "Physiotherapy" "Pilates" "Podiatry" "Polarity Therapy" "Psychotherapy" "Qi Gong" "Reconnective Healing" "Reflexology" "Reiki" "Remedial Massage Therapy" "Shamanic Healing" "Shiatsu" "Sound Therapy" "Spiritual Healing" "Tai Chi" "TFT (Thought Field Therapy)" "Time Line Therapy" "Trigger Point Therapy" "Yoga" "Zen"] <p><b>Speciality</b> (Optional)<br /><br /> [checkbox article-speciality use_label_element "Abundance" "Addictions" "Allergies" "Anti-aging" "Anxiety" "Arthritis" "Birthing" "Cancer" "Children" "Chronic Fatigue" "Depression" "Detoxification" "Eating Disorders" "Fatigue" "Fertility" "Fitness" "Learning Disabilities" "Men’s Health" "Migraine Headaches" "Motivation" "Pain Management" "Preventive Health" "Sleep Disorders" "Smoking Cessation" "Stress Management" "Vision Improvement" "Weight Management" "Women’s Health"]</p> <p>[acceptance book-acceptance] I accept the <a href="/for-practitioners/terms-conditions/">terms & conditions</a>.</p> <p>[submit "??Submit Your Article??"]</p>
This works great – emails sent ok with all correct data.
I also create a post before sending the email by using the wpcf7_before_send_mail hook. In functions.php I have:
remove_all_filters ('wpcf7_before_send_mail'); add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' ); function contactform7_before_send_mail( $cf7 ) { // Submit an Article if ( 6 == $cf7->id ) { $contact_name = $cf7->posted_data["contact-name"]; $contact_email = $cf7->posted_data["contact-email"]; $article_title = $cf7->posted_data["article-title"]; $article_content = $cf7->posted_data["article-content"]; $my_post = array(); $my_post['post_title'] = $article_title; $my_post['post_content'] = $article_content; $my_post['post_status'] = 'draft'; $my_post['comment_status'] = 'open'; $my_post['ping_status'] = 'closed'; $my_post['post_author'] = 1; $my_post['post_category'] = array(17); $new_post_id = wp_insert_post( $my_post ); update_post_meta($new_post_id, 'Contact_Name', $contact_name); update_post_meta($new_post_id, 'Contact_Email', $contact_email); } }
Again this works great but I can’t seem to get at the data for the checkbox fields article-modality and article-speciality.
‘$article_modality = $cf7->posted_data[“article-modality”];’ doesn’t seem to return anything.
Does anybody know of any documentation on this functionality or can help?
Many thanks,
Mark
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘[Plugin: Contact Form 7] $cf7->posted_data & checkbox fields’ is closed to new replies.