_e('Add new Posts to this Pack', 'mgm'); ?> </b> </div> </div> <div class="row brBottom"> <div class="cell width10 textalignleft"> <?php _e('Post', 'mgm'); ?> : </div> <div class="cell width70 textalignleft"> <select name="posts[]" class="width80"> <?php echo mgm_make_combo_options(mgm_get_purchasable_posts($data['exclude_posts']), '', MGM_KEY_VALUE); ?> </select> <div class="tips"> <?php _e("This dropdown will populate with posts as you mark them as purchasable", "mgm"); ?> </div> </div> <div class="cell width20 textalignright"> <input class="button" type="button" onclick="mgm_postpack_post_add()" value="<?php _e('Save', 'mgm'); ?> " />
function post_purchase_gift() { global $wpdb; extract($_POST); // save if (isset($send_gift)) { // user data $user = get_userdata($user_id); $post = get_post($post_id); // expire if (!isset($is_expire) || empty($is_expire)) { $is_expire = 'Y'; } // sql $sql = $wpdb->prepare("REPLACE INTO `" . TBL_MGM_POST_PURCHASES . "` SET `user_id`=%d, `post_id`=%d, \r\r\n\t\t\t \t\t\t\t `is_gift`=%s,`purchase_dt`=NOW(), `is_expire`=%s", $user_id, $post_id, 'Y', $is_expire); // saved if ($wpdb->query($sql)) { $message = sprintf(__('Successfully gifted post - "%s" to member - "%s".', 'mgm'), $post->post_title, $user->display_name); $status = 'success'; } else { $message = sprintf(__('Error while gifting post - "%s" to member - "%s".', 'mgm'), $post->post_title, $user->display_name); $status = 'error'; } // return response echo json_encode(array('status' => $status, 'message' => $message)); exit; } // data $data = array(); // users $data['users'] = mgm_field_values($wpdb->users, 'ID', 'user_login', "AND ID<>1", 'user_login'); // posts $data['posts'] = mgm_get_purchasable_posts(); // load template view $this->load->template('payperpost/post_purchases/gift', array('data' => $data)); }