Esempio n. 1
0
function set_post_content_34($entry, $form)
{
    // Create flatterbox post object
    //Get the current user info to insert into flatterbox information
    $current_user = wp_get_current_user();
    $current_user_name = $current_user->user_login;
    //Set up the flatterbox information to insert
    $my_flatterbox = array('post_title' => $entry["1"] . '\'s ' . $entry["26"] . ' Flatterbox', 'post_type' => 'flatterboxes', 'post_content' => '', 'post_status' => 'publish', 'post_author' => get_current_user_id());
    // Insert the post into the database
    if (!isset($_SESSION["new_flatterbox_id"])) {
        $new_post_id = wp_insert_post($my_flatterbox);
        $newpid = $new_post_id;
    } else {
        $my_flatterbox = array('ID' => $_SESSION["new_flatterbox_id"], 'post_title' => $entry["1"] . '\'s ' . $entry["26"] . ' Flatterbox', 'post_content' => '');
        wp_update_post($my_flatterbox);
        // To update the title
        $newpid = $_SESSION["new_flatterbox_id"];
    }
    $_SESSION["occassion_name"] = $entry["26"];
    wp_set_object_terms($newpid, $entry["26"], 'flatterbox_type', 0);
    //Convert date to ACF's format
    $date = new DateTime($entry["2"]);
    $newdate = $date->Format(Ymd);
    $boxtheme = '';
    switch ($entry["26"]) {
        case 'Birthday':
            $boxtheme = $entry["27"];
            break;
        case 'Anniversary':
            $boxtheme = $entry["28"];
            break;
        case 'Military Gift':
            $boxtheme = $entry["53"];
            break;
        case 'Get Well':
            $boxtheme = $entry["52"];
            break;
        case 'Bar/Bat Mizvah':
            $boxtheme = $entry["51"];
            break;
        case 'New Baby/Parents':
            $boxtheme = $entry["50"];
            break;
        case 'Engagement':
            $boxtheme = $entry["49"];
            break;
        case 'Wedding':
            $boxtheme = $entry["48"];
            break;
        case 'Graduation':
            $boxtheme = $entry["47"];
            break;
        case 'Bridal Shower':
            $boxtheme = $entry["46"];
            break;
        case "Boss' Gift":
            $boxtheme = $entry["45"];
            break;
        case 'Holiday':
            $boxtheme = $entry["44"];
            break;
        case "Valentine's Day":
            $boxtheme = $entry["43"];
            break;
        case "Father's Day":
            $boxtheme = $entry["42"];
            break;
        case 'Sweet 16':
            $boxtheme = $entry["41"];
            break;
        case 'Love You Because...':
            $boxtheme = $entry["40"];
            break;
        case 'Retirement':
            $boxtheme = $entry["39"];
            break;
        case 'Hanukkah':
            $boxtheme = $entry["38"];
            break;
        case "Mother's Day":
            $boxtheme = $entry["37"];
            break;
        case 'Funeral':
            $boxtheme = $entry["36"];
            break;
        case 'New Year Encouragement':
            $boxtheme = $entry["80"];
            break;
        case 'Just Because...':
            $boxtheme = $entry["34"];
            break;
        case 'Divorce Encouragement':
            $boxtheme = $entry["33"];
            break;
        case 'Corporate Meeting':
            $boxtheme = $entry["32"];
            break;
        case "Teacher's Gift":
            $boxtheme = $entry["31"];
            break;
        case 'Christmas':
            $boxtheme = $entry["30"];
            break;
        case "Coach's Gift":
            $boxtheme = $entry["29"];
            break;
        case "Coach's Gift":
            $boxtheme = $entry["29"];
            break;
        case "Baby Shower":
            $boxtheme = $entry["81"];
            break;
    }
    __update_post_meta($newpid, 'occasion', $value = $entry["26"]);
    $_SESSION["occasion"] = $entry["26"];
    __update_post_meta($newpid, 'box_theme', $value = $boxtheme);
    $_SESSION["box_theme"] = $boxtheme;
    __update_post_meta($newpid, 'who_is_this_for', $value = $entry["1"]);
    $_SESSION["who_is_this_for"] = $entry["1"];
    __update_post_meta($newpid, 'who_is_this_from', $value = $entry["65"]);
    $_SESSION["who_is_this_from"] = $entry["65"];
    __update_post_meta($newpid, 'date_of_birthday', $value = $newdate);
    $_SESSION["date_of_birthday"] = $newdate;
    __update_post_meta($newpid, 'birthday_occassion', $value = $entry["3"]);
    $_SESSION["birthday_occassion"] = $entry["3"];
    __update_post_meta($newpid, 'card_style', $value = $_SESSION["cardcolor"]);
    __update_post_meta($newpid, 'card_quantity', $value = $_SESSION["cardquantity"]);
    __update_post_meta($newpid, 'box_style', $value = $_SESSION["boxtype"]);
    __update_post_meta($newpid, 'introductory_card_message', $value = $entry["4"]);
    $_SESSION["introductory_card_message"] = $entry["4"];
    __update_post_meta($newpid, 'special_instructions_to_flatterers', $value = $entry["77"]);
    $_SESSION["special_instructions_to_flatterers"] = $entry["77"];
    __update_post_meta($newpid, 'private', $value = $entry["8"]);
    // Used for Passcode
    $_SESSION["private"] = $entry["8"];
    __update_post_meta($newpid, 'can_invite', $value = $entry["69"]);
    // Used for Flaterers to be able to Invite
    $_SESSION["can_invite"] = $entry["69"];
    __update_post_meta($newpid, 'allow_to_see_eachother', $value = $entry["25"]);
    $_SESSION["allow_to_see_eachother"] = $entry["25"];
    __update_post_meta($newpid, 'allow_to_share', $value = $entry["7"]);
    $_SESSION["allow_to_share"] = $entry["7"];
    __update_post_meta($newpid, 'allow_profanity', $value = $entry["9"]);
    $_SESSION["allow_profanity"] = $entry["9"];
    __update_post_meta($newpid, 'notification_frequency', $value = $entry["10"]);
    $_SESSION["notification_frequency"] = $entry["10"];
    __update_post_meta($newpid, 'total_price', $value = $_SESSION["totalprice"]);
    __update_post_meta($newpid, 'box_image_url', $value = $_SESSION["boxtypeimg"]);
    //$_SESSION["boxtypeimg"]
    __update_post_meta($newpid, 'box_color', $value = $_SESSION["boxcolor"]);
    //__update_post_meta( $newpid, 'title_card_headline', $value = $entry["73"]); // Removed from form
    __update_post_meta($newpid, 'live_event', $value = $entry["78"]);
    // Dates for Deadlines
    __update_post_meta($newpid, 'date_of_delivery', $value = $newdate);
    __update_post_meta($newpid, 'date_of_project_complete', $value = $newdate);
    __update_post_meta($newpid, 'date_sentiments_complete', $value = $newdate);
    //$current_user = wp_get_current_user();
    //$uniquestart = $current_user->user_email.$newpid;
    //__update_post_meta( $newpid, 'unique_url', $value = md5(uniqid($uniquestart, true)));
    //Order Items
    __update_post_meta($newpid, 'order_count', $value = '');
    __update_post_meta($newpid, 'add10', $value = '0');
    // Only Update if new
    if (!isset($_SESSION["new_flatterbox_id"])) {
        __update_post_meta($newpid, 'unique_url', $value = getURLToken(10));
    }
    // Dates for Deadlines
    //Convert dates to ACF's format
    $date = new DateTime($entry["2"]);
    $delivery = $date->Format(Ymd);
    $date = new DateTime($entry["19"]);
    // Was 19? Which doesnt exist
    $project = $date->Format(Ymd);
    $date = new DateTime($entry["54"]);
    $sentiment = $date->Format(Ymd);
    __update_post_meta($newpid, 'date_of_delivery', $value = $delivery);
    $_SESSION["date_of_delivery"] = $delivery;
    __update_post_meta($newpid, 'date_of_project_complete', $value = $project);
    $_SESSION["date_of_project_complete"] = $project;
    __update_post_meta($newpid, 'date_sentiments_complete', $value = $sentiment);
    $_SESSION["date_sentiments_complete"] = $sentiment;
    $_SESSION["new_flatterbox_id"] = $newpid;
    if ($entry["84"] == "1") {
        wp_redirect(site_url() . "/my-flatterbox/");
        exit;
    }
}
global $current_user;
get_currentuserinfo();
//$current_userID = $current_user->ID, // I could also use $user_ID, right?
$current_userID = get_current_user_id();
$args = array('author' => $current_userID, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'flatterboxes', 'posts_per_page' => -1);
// get his posts 'ASC'
$current_user_posts = get_posts($args);
$i = 1;
foreach ($current_user_posts as $post) {
    setup_postdata($post);
    // Check for URL variable -- Can be removed once legacy items are covered
    if (strlen(get_field('unique_url')) == 0) {
        //$current_user = wp_get_current_user();
        //$uniquestart = $current_user->user_email.get_the_ID();
        //__update_post_meta( get_the_ID(), 'unique_url', $value = md5(uniqid($uniquestart, true)));
        __update_post_meta(get_the_ID(), 'unique_url', $value = getURLToken(10));
    }
    ?>
		
			<div class="event anchor-<?php 
    the_id();
    ?>
" id="flatterbox-<?php 
    echo $i;
    ?>
">
				<div class="detail">
					<div class="img-holder">
						<?php 
    foreach (get_the_terms(get_the_ID(), 'flatterbox_type') as $cat) {
        $catimage = z_taxonomy_image_url($cat->term_id);