function bl_my_listings() { global $wpdb, $post; $current_url = get_permalink($post->ID); $return_text = ""; if (!is_user_logged_in()) { $return_text .= "<p>" . __("You need to be Logged In to see your Listings.", "bepro-listings") . "</p>"; $args = array('echo' => true, 'redirect' => $current_url, 'form_id' => 'loginform', 'label_username' => __('Username'), 'label_password' => __('Password'), 'label_remember' => __('Remember Me'), 'label_log_in' => __('Log In'), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => NULL, 'value_remember' => false); wp_login_form($args); return; } $types = listing_types(); $current_user = wp_get_current_user(); $user_id = $current_user->id; if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) { $success = false; $success = bepro_listings_save(); if ($success) { $success_message = apply_filters("bepro_form_success_message", "Listing Successfully Saved"); $message = "<span class='bl_succsss_message'>" . __($success_message, "bepro-listings") . "</span>"; } else { $fail_message = apply_filters("bepro_form_fail_message", __("Issue saving your listing. Please contact the website administrator", "bepro-listings")); $message = "<span class='bl_fail_message'>" . __($fail_message, "bepro-listings") . "</span>"; } $current_user = wp_get_current_user(); $current_url = get_permalink($post->ID); echo "<span class='classified_message'>" . $message . "</span>"; } if (!empty($_GET["bl_manage"])) { if (!empty($_GET["bl_id"])) { bl_profile_update_listing_content(); } else { bl_profile_add_listing_content(); } } else { $data = get_option("bepro_listings"); // get records if (@$data["require_payment"]) { $items = $wpdb->get_results("SELECT geo.*, orders.status as order_status, orders.expires, wp_posts.post_title, wp_posts.post_status FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " as geo \n\t\t\t\tLEFT JOIN " . $wpdb->prefix . "posts as wp_posts on wp_posts.ID = geo.post_id \n\t\t\t\tLEFT JOIN " . BEPRO_LISTINGS_ORDERS_TABLE_NAME . " AS orders on orders.bl_order_id = geo.bl_order_id WHERE wp_posts.post_status != 'trash' AND wp_posts.post_author = " . $user_id); } else { $items = $wpdb->get_results("SELECT geo.*, wp_posts.post_title, wp_posts.post_status FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " as geo \n\t\t\t\tLEFT JOIN " . $wpdb->prefix . "posts as wp_posts on wp_posts.ID = geo.post_id WHERE wp_posts.post_status != 'trash' AND wp_posts.post_author = " . $user_id); } $listing_url = "?bl_manage=1&bl_id="; $add_listing_button = "<p><a href='" . $listing_url . "'>" . __("Add a Listing") . "</a></p>"; //allow addons to override create listing button $return_text .= apply_filters("bl_change_add_listing_button", $add_listing_button, $listing_url); //allow addons to change profile template $bl_my_list_template = apply_filters("bl_change_my_list_template", dirname(__FILE__) . '/templates/list.php', $items); ob_start(); if (!empty($bl_my_list_template)) { include $bl_my_list_template; } $return_text .= ob_get_clean(); return $return_text; } }
function bl_my_listings() { global $wpdb, $post; $current_url = get_permalink($post->ID); if (!is_user_logged_in()) { echo "<p>You need to be Logged In to see your Listings.</p>"; $args = array('echo' => true, 'redirect' => $current_url, 'form_id' => 'loginform', 'label_username' => __('Username'), 'label_password' => __('Password'), 'label_remember' => __('Remember Me'), 'label_log_in' => __('Log In'), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => NULL, 'value_remember' => false); wp_login_form($args); return; } $types = listing_types(); $current_user = wp_get_current_user(); $user_id = $current_user->id; if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) { $success = false; $success = bepro_listings_save(); if ($success) { $message = urlencode("Success saving listing"); } else { $message = urlencode("Error saving listing"); } $current_user = wp_get_current_user(); $current_url = get_permalink($post->ID); wp_redirect($current_url . "?message=" . $message); exit; } if (!empty($_GET["bl_manage"])) { if (!empty($_GET["bl_id"])) { bl_profile_update_listing_content(); } else { bl_profile_add_listing_content(); } } else { // get records $items = $wpdb->get_results("SELECT geo.*, wp_posts.post_title, wp_posts.post_status FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " as geo \r\n\t\t\tLEFT JOIN " . $wpdb->prefix . "posts as wp_posts on wp_posts.ID = geo.post_id WHERE wp_posts.post_status != 'trash' AND wp_posts.post_author = " . $user_id); $listing_url = "?bl_manage=1&bl_id="; echo "<p><a href='" . $listing_url . "'>Add a Listing</a></p>"; require dirname(__FILE__) . '/templates/list.php'; } }