Frontend editing, Frontend user dashboard

I am creating a website so that users can submit their articles from the front end. I have quite a few things set up:

  • The ability to submit custom post types from the front end
  • Blocked from the back-end.

I’d like to create a page (for logged in users) labeled “my posts” or my “submissions” that will show logged in users their own custom post post types and their status so that they know what’s been published, what will be published in the future, pending, drafts (so they can go back and edit), and pending (so that I as Editor, know when an article is ready for my review).

Read More

I’m guess I’m looking for a frontend user dashboard. I’ve tried WP User Frontend, but it clashes with s2member and won’t show posts from s2member registered users.

I just need something simple that will allow users easy access from the front end to manage their posts. I’ve been trying plugin after plugin and adding things to my short code creator but nothing works the way I need it to.

It doesn’t have to be pretty, just a simple code that a non coder (like me) update per by custom post types.

To explain further, i’d like to have one code on a page shows the users all the deals they’ve submitted (and their status), and another code to show users all the articles they’ve submitted (and their status), etc.

Any help would be very useful

Thanks in advance!

Related posts

Leave a Reply

1 comment

  1. I have Something that i use from time to time when i need something like that:

    <?php
    /*
    Plugin Name: List User Posts
    Plugin URI: http://en.bainternet.info
    Description: lists user posts on the front end
    Version: 0.1
    Author: Bainternet
    Author URI: http://en.bainternet.info
    */
    
    if (!class_exists('list_user_posts')){
        /**
        * list_user_posts
        * @author Ohad Raz
        */
        class list_user_posts
        {
            /**
             * __construct class constructor
             * 
             * @author Ohad Raz
             * @param array $args
             */
            function __construct($args = array())
            {
                add_shortcode('user_posts', array($this,list_user_posts));
            }
    
            /**
             * list_user_posts shortcode handler
             * 
             * @author Ohad Raz
             * @param  array  $attr    shortcode attributes
             * @param  string $content shortcode content
             * @return string
             */
            public function list_user_posts($attr = array(), $content = null)
            {
                extract(shortcode_atts(array(
                        'post_type' => 'post',
                        'number' => 10,
                    ), $attr));
    
                //if the user is not logged in the give him a link to log in
                if (!is_user_logged_in()){
                    return sprintf(__('You Need to <a href="%s">Login</a> to see your posts'),wp_login_url(get_permalink()));
                }
                //this is for pagination
                $pagenum = isset( $_GET['pagenum'] ) ? intval( $_GET['pagenum'] ) : 1;
    
                //get user's posts
                $args = array(
                    'author' => get_current_user_id(), //this makes the query pull post form the current user only
                    'post_status' => array('draft', 'future', 'pending', 'publish'),
                    'post_type' => $post_type,
                    'posts_per_page' => $number,
                    'paged' => $pagenum
                );
                $user_posts = new WP_Query( $args );
    
                $retVal = '';
                if ( $user_posts->have_posts() ) {
    
                    //set table headers
                    $retVal = '
                        <table class="user-posts-table" cellpadding="0" cellspacing="0">
                            <thead>
                                <tr>
                                    <th>'.__( 'Title', 'lup' ).'</th>
                                    <th>'.__( 'Status', 'lup' ).'</th>
                                    <th>'.__( 'Actions', 'lup' ).'</th>
                                </tr>
                            </thead>
                            <tbody>';
                    //loop over and add each post to the table
                    global $post;
                    $temp = $post;
                    while ($user_posts->have_posts()){
                        $user_posts->the_post();
                        $title = $post->post_title;
                        $link = '<a href="'.get_permalink().'" title="'.sprintf( esc_attr__( 'Permalink to %s', 'lup' ), the_title_attribute( 'echo=0' ) ).'" rel="bookmark">'.$title.'</a>';
                        $retVal .= 
                                '<tr>
                                    <td>
                                        '.( in_array( $post->post_status, array('draft', 'future', 'pending') ) ? $title : $link).'
                                    </td>
                                    <td>
                                        '.$post->post_status .'
                                    </td>
                                    <td>
                                        <a href="LINK_TO_YOUR_EDIT_PAGE"><span style="color: green;">'. __( 'Edit', 'lup' ).'</span></a>
                                        <a href="LINK TO YOUR DELETE PAGE"><span style="color: red;">'.__( 'Delete', 'lup' ).'</span></a>
                                    </td>
                                </tr>';
                    }
                    $retVal .= '</tbody></table>';
    
                    //create pagination (if needed)
                    if ($user_posts->found_posts > $number ){
                        $pagination = paginate_links( array(
                            'base' => add_query_arg( 'pagenum', '%#%' ),
                            'format' => '',
                            'prev_text' => __( '&laquo;', 'lup' ),
                            'next_text' => __( '&raquo;', 'lup' ),
                            'total' => $user_posts->max_num_pages,
                            'current' => $pagenum
                            ) 
                        );
                        if ( $pagination ) {
                            $retVal .= '<div class="pagination">'.$pagination .'</div>';
                        }
                    }
                    //return table of posts
                    return $retVal;
                }else{
                    //  no posts for this users found
                    return  __("No Posts Found");
                }
            }
    
        }//end list_user_posts class
    }//end if
    new list_user_posts();
    

    Its commented all over the place so you can understand whats going on there.

    Usage
    simply create a page and add this shortcode:
    [user_posts]
    which will give you a list of posts by the logged in user.

    You can also change the post type like so:
    [user_posts post_type="deal" number="5"]