Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: Contact Form 7 Extender
- * Description: This plugin saves input data from a form to the database.
- * Version: 1.1
- * Author: Marcus Thienert, Marco Gajardo
- */
- add_action('wpcf7_before_send_mail', 'createPostData' );
- function createPostData() {
- //get user id
- //$user = get_userdatabylogin('myusername');
- //$user = get_user_by('login', $user_login);
- //$udi = $user->ID;
- get_currentuserinfo();
- if ($_POST['aut'] == '') {
- // Create post object
- $my_post = array(
- 'post_title' => $_POST['title'],
- 'post_content' => $_POST['Description'],
- 'post_status' => 'pending',
- 'post_author' => 3,
- 'post_category' => array($_POST['postcategory'])
- );
- } else {
- $my_post = array(
- 'post_title' => $_POST['title'],
- 'post_content' => $_POST['Description'],
- 'post_status' => 'publish',
- //'post_author' => $user,
- 'post_author' => $user_ID,
- 'post_category' => array($_POST['postcategory'])
- );
- }
- //Insert the post into the database
- $post_id = wp_insert_post( $my_post );
- //Delete Date-Conf not Req.
- if ($_POST['Earlydate'] == date('Y-m-d')) {
- $_POST['Earlydate'] = "";
- }
- if ($_POST['Abstractdate'] == date('Y-m-d')) {
- $_POST['Abstractdate'] = "";
- }
- if ($_POST['Regdate'] == date('Y-m-d')) {
- $_POST['Regdate'] = "";
- }
- //insert postmeta:
- update_post_meta($post_id, 'location', $_POST['location']);
- update_post_meta($post_id, 'date_start', $_POST['Startdate']);
- update_post_meta($post_id, 'date_end', $_POST['Enddate']);
- update_post_meta($post_id, 'email', $_POST['email-Contact']);
- update_post_meta($post_id, 'url', $_POST['URL']);
- update_post_meta($post_id, 'date_registration', $_POST['Regdate']);
- update_post_meta($post_id, 'date_early_registration', $_POST['Earlydate']);
- update_post_meta($post_id, 'date_abstract_deadline', $_POST['Abstractdate']);
- update_post_meta($post_id, 'date_deadline', $_POST['JobDate']);
- //insert tags to database
- $tagarray = explode(",",trim($_POST['Tagsconference']));
- wp_set_post_tags($post_id, $tagarray);
- //insert categories
- $post_categories = array ();
- $post_categories[4] = 'conferences';
- $postid = (int)$post_ID;
- wp_set_post_categories( $postID, $post_categories[4]);
- return;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement