Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Improve My City

    (@improvemycity)

    Hello,

    You mean to see only their own issues?

    Thread Starter uchiha266

    (@uchiha266)

    Yes a page where they can see the issues they published

    Plugin Author Improve My City

    (@improvemycity)

    Right now the issues that belong to users, are tagged with an icon.

    This is a new feature request and not really a support question.
    We are gonna implement this at some point.

    For now I am closing the issue.

    mslave

    (@mslave)

    edit this “imc-core-filter-func.php” in functions folder

    find for this: Returns issues for user

    and replace it whith this

    
    /**
     * 13.07
     * Returns issues for user
     *
     */
    
    function imcLoadIssuesForUsers($paged, $page, $user_id, $status, $category){
    
        $imported_sstatus = explode(",", $status);
        $imported_scategory = explode(",", $category);
    
        //the filtering is for users so -plus user's pending issues-
        $include_pending = true;
    
        if($imported_scategory && !$imported_sstatus) {
            $filter = imcFilterIssuesByCategory($imported_scategory,$include_pending);
            $pendingOfUser = get_posts(array(
                'post_status' => 'pending',
                'post_type' => 'imc_issues',
                'author' => $user_id,
                'posts_per_page' => -1,
                'post__not_in' => $filter,
            ));
    
            $allPublish = get_posts(array(
                'post_status' => 'publish',
                'post_type' => 'imc_issues',
    			'author' => $user_id,
                'posts_per_page' => -1,
                'post__not_in' => $filter,
            ));
        }elseif(!$imported_scategory && $imported_sstatus){
            $filter = imcFilterIssuesByStatus($imported_sstatus,$include_pending);
            $pendingOfUser = get_posts(array(
                'post_status' => 'pending',
                'post_type' => 'imc_issues',
                'author' => $user_id,
                'posts_per_page' => -1,
                'post__not_in' => $filter,
            ));
            $allPublish = get_posts(array(
                'post_status' => 'publish',
                'post_type' => 'imc_issues',
    			'author' => $user_id,
                'posts_per_page' => -1,
                'post__not_in' => $filter,
            ));
        }elseif($imported_scategory && $imported_sstatus){
            $filter1 = imcFilterIssuesByCategory($imported_scategory,$include_pending);
            $filter2 = imcFilterIssuesByStatus($imported_sstatus,$include_pending);
            $mergedfilters = array_merge($filter1, $filter2); //combine queries
            $uniqueposts_filters = array_unique($mergedfilters); //remove duplicate post ids
            $pendingOfUser = get_posts(array(
                'post_status' => 'pending',
                'post_type' => 'imc_issues',
                'author' => $user_id,
                'posts_per_page' => -1,
                'post__not_in' => $uniqueposts_filters,
            ));
            $allPublish = get_posts(array(
                'post_status' => 'publish',
                'post_type' => 'imc_issues',
    			'author' => $user_id,
                'posts_per_page' => -1,
                'post__not_in' => $uniqueposts_filters,
            ));
        }else{
            //first query
            $pendingOfUser = get_posts(array(
                'post_status' => 'pending',
                'post_type' => 'imc_issues',
                'author' => $user_id,
                'posts_per_page' => -1,
            ));
            //second query
            $allPublish = get_posts(array(
                'post_status' => 'publish',
                'post_type' => 'imc_issues',
    			'author' => $user_id,
                'posts_per_page' => -1,
            ));
        }
    
        $mergedposts = array_merge($pendingOfUser, $allPublish); //combine queries
    
        $postids = array();
        foreach ($mergedposts as $item) {
            $postids[] = $item->ID; //create a new query only of the post ids
        }
    
        $uniqueposts = array_unique($postids); //remove duplicate post ids
    
        if(!empty($uniqueposts)) {
            $custom_query_args = array(
                'post_type' => 'imc_issues',
                'post_status' => array( 'publish','pending' ),
                'post__in' => $uniqueposts,
                'paged' => $paged,
                'posts_per_page' => $page,
            );
        }else{
            $custom_query_args = array(
                'post_type' => 'imc_issues',
                'post_status' => array( 'publish' ),
                'paged' => $paged,
                'posts_per_page' => $page,
            );
        }
    
        return $custom_query_args;
    }
    
    ?>
    
    • This reply was modified 6 years ago by mslave.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Create a mechanim to allow users see only their issues’ is closed to new replies.