function frontier_user_posts($atts)
{
    global $wp_roles;
    global $current_user;
    global $post;
    $sc_allowed_post_types = fp_get_option_array('fps_sc_allowed_in', array("page"));
    //new in version 3.6.6, admin can choose wich post types are aloowed
    if (has_shortcode($post->post_content, 'frontier-post') && in_array($post->post_type, $sc_allowed_post_types)) {
        if (is_user_logged_in()) {
            //if ( !is_page(get_the_id()) )
            if (!in_array($post->post_type, $sc_allowed_post_types)) {
                die('<center><h1>ERROR: ' . __("frontier-post Shortcode only allowed in pages", "frontier-post") . " (" . $post->post_type . ")</h1></center>");
                return;
            }
            if (isset($_POST['task'])) {
                $post_task = $_POST['task'];
            } else {
                if (isset($_GET['task'])) {
                    $post_task = $_GET['task'];
                } else {
                    $post_task = "notaskset";
                }
            }
            $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
            $fpost_sc_parms = shortcode_atts(array('frontier_mode' => 'none', 'frontier_parent_cat_id' => 0, 'frontier_cat_id' => 0, 'frontier_list_cat_id' => 0, 'frontier_list_all_posts' => 'false', 'frontier_list_pending_posts' => 'false', 'frontier_list_draft_posts' => 'false', 'frontier_list_text_before' => '', 'frontier_edit_text_before' => '', 'frontier_myid' => $post->ID, 'frontier_page_id' => $post->ID, 'frontier_return_text' => __("Save & Return", "frontier-post"), 'frontier_add_link_text' => '', 'frontier_add_post_type' => 'post', 'frontier_list_post_types' => 'post', 'frontier_custom_tax' => '', 'frontier_custom_tax_layout' => '', 'frontier_edit_form' => fp_get_option("fps_default_form", "standard"), 'frontier_editor_height' => fp_get_option_int("fps_editor_lines", 300), 'frontier_quick_editor_height' => fp_get_option_int("fps_quick_editor_lines", 200), 'frontier_list_form' => fp_get_option("fps_default_list", "list"), 'fps_cache_time_tax_lists' => fp_get_option_int("fps_cache_time_tax_lists", 30 * 60), 'frontier_pagination' => 'true', 'frontier_ppp' => (int) fp_get_option('fps_ppp', 5), 'frontier_user_status' => ''), $atts);
            // support for url link based creation of custom post types
            if (isset($_GET['task']) && $_GET['task'] == "new" && isset($_GET['frontier_add_post_type'])) {
                $tmp_post_type = $_GET['frontier_add_post_type'];
                $tmp_post_type_list = fp_get_option_array('fps_custom_post_type_list', array());
                if (in_array($tmp_post_type, $tmp_post_type_list)) {
                    $fpost_sc_parms['frontier_add_post_type'] = $tmp_post_type;
                }
            }
            // Remove quotes from post type
            $fpost_sc_parms['frontier_add_post_type'] = str_replace("'", "", $fpost_sc_parms['frontier_add_post_type']);
            $fpost_sc_parms['frontier_add_post_type'] = str_replace('"', '', $fpost_sc_parms['frontier_add_post_type']);
            //If Category parsed from widget assign it instead of category from shortcode
            if (isset($_GET['frontier_new_cat_widget']) && $_GET['frontier_new_cat_widget'] == "true") {
                $_REQUEST['frontier_new_cat_widget'] = "true";
                $fpost_sc_parms['frontier_cat_id'] = isset($_GET['frontier_cat_id']) ? $_GET['frontier_cat_id'] : 0;
            }
            //Change Categories to array
            $fpost_sc_parms['frontier_cat_id'] = fp_list2array($fpost_sc_parms['frontier_cat_id']);
            $fpost_sc_parms['frontier_list_cat_id'] = fp_list2array($fpost_sc_parms['frontier_list_cat_id']);
            $fpost_sc_parms['frontier_list_post_types'] = fp_list2array($fpost_sc_parms['frontier_list_post_types']);
            $fpost_sc_parms['frontier_custom_tax'] = fp_list2array($fpost_sc_parms['frontier_custom_tax']);
            $fpost_sc_parms['frontier_custom_tax_layout'] = fp_list2array($fpost_sc_parms['frontier_custom_tax_layout']);
            $fpost_sc_parms['frontier_user_status'] = fp_list2array($fpost_sc_parms['frontier_user_status']);
            extract($fpost_sc_parms);
            // if mode is add, go directly to show form - enables use directly on several pages
            if ($frontier_mode == "add" && $post_task != 'delete') {
                $post_task = "new";
            }
            ob_start();
            switch ($post_task) {
                case 'new':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($fpost_sc_parms);
                    } else {
                        frontier_post_add_edit($fpost_sc_parms);
                    }
                    break;
                case 'edit':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($fpost_sc_parms);
                    } else {
                        frontier_post_add_edit($fpost_sc_parms);
                    }
                    break;
                case 'delete':
                    if ($post_action == "wpfrtp_delete_post") {
                        frontier_execute_delete_post($fpost_sc_parms);
                    } else {
                        frontier_prepare_delete_post($fpost_sc_parms);
                    }
                    break;
                case 'approve':
                    if ($post_action == "wpfrtp_approve_post") {
                        frontier_execute_approve_post($fpost_sc_parms);
                    } else {
                        frontier_prepare_approve_post($fpost_sc_parms);
                    }
                    break;
                case 'clone':
                    frontier_clone_post($fpost_sc_parms);
                    break;
                default:
                    frontier_user_post_list($fpost_sc_parms);
                    break;
            }
            //return content to shortcode for output
            $fp_content = ob_get_contents();
            ob_end_clean();
            return $fp_content;
        } else {
            echo fp_login_text();
        }
        // user_logged_in
    } else {
        //Shortcode called from enything else than page, not allowed
        if (!in_array($post->post_type, $sc_allowed_post_types) && is_singular()) {
            // Only show warning if single post
            $sing = is_singular() ? "S" : "M";
            echo '<br><div id="frontier-post-alert">frontier-post shortcode ' . __("only allowed in", "frontier-post") . ': ' . implode(", ", $sc_allowed_post_types) . ' - This post type: (' . $post->post_type . ') - (' . $post->ID . '/' . $sing . ')</div><br>';
            return;
        }
    }
    // has_shortcode
}
function frontier_user_posts($atts)
{
    global $wp_roles;
    global $current_user;
    global $post;
    if (has_shortcode($post->post_content, 'frontier-post') && $post->post_type == 'page') {
        if (is_user_logged_in()) {
            //if ( !is_page(get_the_id()) )
            if ($post->post_type != 'page') {
                die('<center><h1>ERROR: ' . __("frontier-post Shortcode only allowed in pages", "frontier-post") . '</h1></center>');
                return;
            }
            //error_log("Custom tax from settings ----->");
            //error_log(print_r(fp_get_option_array("fps_custom_tax_list"), true));
            /*
            error_log("Get var---->");
            error_log(print_r($_GET, true));
            */
            if (isset($_POST['task'])) {
                $post_task = $_POST['task'];
            } else {
                if (isset($_GET['task'])) {
                    $post_task = $_GET['task'];
                } else {
                    $post_task = "notaskset";
                }
            }
            //$post_task 		= isset($_GET['task']) ? $_GET['task'] : "notaskset";
            $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
            /*
            error_log("Post task---->".$post_task);
            
            error_log("Post action---->".$post_action);
            error_log(print_r($_POST, true));
            */
            $frontier_post_shortcode_parms = shortcode_atts(array('frontier_mode' => 'none', 'frontier_parent_cat_id' => 0, 'frontier_cat_id' => 0, 'frontier_list_cat_id' => 0, 'frontier_list_all_posts' => 'false', 'frontier_list_pending_posts' => 'false', 'frontier_list_text_before' => '', 'frontier_edit_text_before' => '', 'frontier_myid' => $post->ID, 'frontier_page_id' => $post->ID, 'frontier_return_text' => __("Save & Return", "frontier-post"), 'frontier_add_link_text' => '', 'frontier_add_post_type' => 'post', 'frontier_list_post_types' => 'post', 'frontier_custom_tax' => '', 'frontier_custom_tax_layout' => '', 'frontier_edit_form' => fp_get_option("fps_default_form", "standard"), 'frontier_editor_height' => fp_get_option_int("fps_editor_lines", 300), 'frontier_list_form' => fp_get_option("fps_default_list", "list"), 'fps_cache_time_tax_lists' => fp_get_option_int("fps_cache_time_tax_lists", 30 * 60)), $atts);
            //error_log(print_r($frontier_post_shortcode_parms,true));
            //If Category parsed from widget assign it instead of category from shortcode
            if (isset($_GET['frontier_new_cat_widget']) && $_GET['frontier_new_cat_widget'] == "true") {
                $_REQUEST['frontier_new_cat_widget'] = "true";
                $frontier_post_shortcode_parms['frontier_cat_id'] = isset($_GET['frontier_cat_id']) ? $_GET['frontier_cat_id'] : 0;
            }
            //Change Categories to array
            $frontier_post_shortcode_parms['frontier_cat_id'] = fp_list2array($frontier_post_shortcode_parms['frontier_cat_id']);
            $frontier_post_shortcode_parms['frontier_list_cat_id'] = fp_list2array($frontier_post_shortcode_parms['frontier_list_cat_id']);
            $frontier_post_shortcode_parms['frontier_list_post_types'] = fp_list2array($frontier_post_shortcode_parms['frontier_list_post_types']);
            $frontier_post_shortcode_parms['frontier_custom_tax'] = fp_list2array($frontier_post_shortcode_parms['frontier_custom_tax']);
            $frontier_post_shortcode_parms['frontier_custom_tax_layout'] = fp_list2array($frontier_post_shortcode_parms['frontier_custom_tax_layout']);
            extract($frontier_post_shortcode_parms);
            // if mode is add, go directly to show form - enables use directly on several pages
            if ($frontier_mode == "add") {
                $post_task = "new";
            }
            ob_start();
            switch ($post_task) {
                case 'new':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($frontier_post_shortcode_parms);
                    } else {
                        frontier_post_add_edit($frontier_post_shortcode_parms);
                    }
                    break;
                case 'edit':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($frontier_post_shortcode_parms);
                    } else {
                        frontier_post_add_edit($frontier_post_shortcode_parms);
                    }
                    break;
                case 'delete':
                    if ($post_action == "wpfrtp_delete_post") {
                        frontier_execute_delete_post($frontier_post_shortcode_parms);
                    } else {
                        frontier_prepare_delete_post($frontier_post_shortcode_parms);
                    }
                    break;
                default:
                    frontier_user_post_list($frontier_post_shortcode_parms);
                    break;
            }
            //return content to shortcode for output
            $fp_content = ob_get_contents();
            ob_end_clean();
            return $fp_content;
        } else {
            echo fp_login_text();
        }
        // user_logged_in
    } else {
        //Shortcode called from post, not allowed
        if (is_singular()) {
            // Only show warning if single post
            echo '<br><div id="frontier-post-alert">frontier-post shortcode ' . __("not allowed in posts, only pages !", "frontier-post") . '</div><br>';
            return;
        }
    }
    // has_shortcode
}