{\rtf1\ansi\ansicpg1252\cocoartf2868 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;\red35\green37\blue38;\red240\green241\blue244;} {\*\expandedcolortbl;;\cssrgb\c18039\c19216\c20000;\cssrgb\c95294\c95686\c96471;} \paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 \deftab720 \pard\pardeftab720\partightenfactor0 \f0\fs21 \cf2 \cb3 \expnd0\expndtw0\kerning0 \outl0\strokewidth0 \strokec2 'POST',\ 'callback' => 'b2brain_handle_event_submission',\ 'permission_callback' => '__return_true',\ ));\ \}\ \ function b2brain_handle_event_submission(WP_REST_Request $request) \{\ $user_email = sanitize_email($request->get_param('user_email'));\ $csv_data = $request->get_param('csv_data');\ $honeypot = $request->get_param('website_url');\ $form_loaded_at = intval($request->get_param('form_loaded_at'));\ \ if (!empty($honeypot)) \{\ return new WP_REST_Response(array('success' => false, 'message' => 'Submission rejected.'), 400);\ \}\ \ $current_time = time();\ if (($current_time - $form_loaded_at) < 5) \{\ return new WP_REST_Response(array('success' => false, 'message' => 'Please take your time to fill out the form.'), 400);\ \}\ \ if (empty($user_email) || !is_email($user_email)) \{\ return new WP_REST_Response(array('success' => false, 'message' => 'Please provide a valid email address.'), 400);\ \}\ \ $free_domains = array('gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'aol.com', 'icloud.com', 'mail.com', 'protonmail.com', 'zoho.com', 'yandex.com', 'gmx.com', 'live.com', 'yahoo.co.uk', 'yahoo.co.in', 'hotmail.co.uk', 'googlemail.com');\ $email_domain = strtolower(substr(strrchr($user_email, '@'), 1));\ if (in_array($email_domain, $free_domains)) \{\ return new WP_REST_Response(array('success' => false, 'message' => 'Please use a business email address.'), 400);\ \}\ \ if (empty($csv_data)) \{\ return new WP_REST_Response(array('success' => false, 'message' => 'No event data provided.'), 400);\ \}\ \ $upload_dir = wp_upload_dir();\ $csv_filename = 'events_' . sanitize_file_name($user_email) . '_' . time() . '.csv';\ $csv_filepath = $upload_dir['basedir'] . '/' . $csv_filename;\ file_put_contents($csv_filepath, $csv_data);\ \ $to = 'support@b2brain.com';\ $subject = 'Event list from ' . $user_email;\ $message = "Hello,\\n\\nA new event list has been submitted.\\n\\nSubmitted by: " . $user_email . "\\nSubmission time: " . current_time('mysql') . "\\n\\nPlease find the event details in the attached CSV file.\\n\\n---\\nThis is an automated message from the B2Brain Event Submission form.";\ \ $headers = array(\ 'From: hello@b2brain.com',\ 'Reply-To: ' . $user_email,\ 'Cc: ' . $user_email,\ 'Content-Type: text/plain; charset=UTF-8'\ );\ \ $sent = wp_mail($to, $subject, $message, $headers, array($csv_filepath));\ \ if (file_exists($csv_filepath)) unlink($csv_filepath);\ \ if ($sent) \{\ return new WP_REST_Response(array('success' => true, 'message' => 'Events submitted successfully! A confirmation has been sent to your email.'), 200);\ \} else \{\ error_log('B2Brain Event Submission: Failed to send email to ' . $to);\ return new WP_REST_Response(array('success' => false, 'message' => 'Failed to send email. Please try again or contact support.'), 500);\ \}\ \}\ \ add_shortcode('b2brain_event_form', 'b2brain_render_event_form');\ function b2brain_render_event_form($atts) \{\ $api_url = esc_url(rest_url('b2brain/v1'));\ \ return '
\ \ \ \ \ \ \ \
\
\
\
\
\
\

\ \ Add Event\

\
\ \
\ \ \
\
\
\ \ \
\
\ \ \
\
\ \ \
\
\
\ \ \
\
\
\ \ \
\
\ \ \ \
\
\
\ \ \
\
\ \ \
\
\
\
\
\
\

\ \ Bulk Upload\

\
\

Download our template, fill it with your event details, and upload it back.

\ \
\
\ \ \
\
\
\
\ \
\
\ \
\

No events added yet

\

Add events using the form above or upload a CSV file with your event details.

\
\
\
\ \ \
';\ \}} https://www.b2brain.com/post-sitemap.xml 2026-03-28T19:21:10+00:00 https://www.b2brain.com/page-sitemap.xml 2026-04-02T06:45:10+00:00 https://www.b2brain.com/event-sitemap.xml 2026-03-26T19:39:16+00:00 https://www.b2brain.com/wpm-testimonial-sitemap.xml 2021-04-29T05:02:00+00:00 https://www.b2brain.com/category-sitemap.xml 2026-03-28T19:21:10+00:00 https://www.b2brain.com/post_tag-sitemap.xml 2026-03-25T06:55:50+00:00 https://www.b2brain.com/author-sitemap.xml 2026-03-18T11:47:12+00:00