Home Forums Plugin Support WP User Frontend (Free Version) "Admin" Edit All Posts?

This topic is: resolved

This topic contains 6 replies, has 3 voices, and was last updated by  Tareq Hasan 5 years, 11 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #5394

    springboard
    Participant
    Post count: 8

    I'm in the middle of developing a “web app” with this plugin, allowing individuals to apply for a grant on the front end by creating a custom post type post. I have different levels of access for the WordPress users. We have a ‘Super Admin', which is basically a user that can access the default WP Admin panel, ‘Regular Admin' members are board members that approve or deny the grants from the front end of the site, and ‘Applicants' which should only be able to see their applications, the application statuses, and grant application page from the front end as well.

    The default functionality of the WPUF is to only let users see their own posts. This works fine for the applicants, but is there a way to give the ‘Regular Admin' members the ability to see all posts of a certain post type and edit them as well? I also need to have additional fields to edit the post and approve/deny the grants that should only be seen by the ‘Regular Admin' users.

    Are these tasks doable?

    Thanks for the help!

    #5435

    Mahi
    Member
    Post count: 1555

    Hello,

    Sorry for being late reply. So, you want to show “regular Admins” all post on frontend ?

    Why now give them editor permission and let them handle backend and hide/restrict menus from them ?

    #5439

    springboard
    Participant
    Post count: 8

    I agree with that logic but my client sees otherwise. They want their board members to not see the WordPress admin if possible. If that's not possible I understand but it would make our lives easier if we could give them the ability to approve/deny from the front end. I already know how to deal with the field that approves or denies their application, but I'm stuck on the option to give their board members the Ability to see all applications from the front end of the site.

    I've looked through all the options to see if its possible and I don't see anything that implies that. If I need to do custom edits to the plugin code I can, but I would like to be pointed in the right direction. Where should I look in the files?

    #5451

    springboard
    Participant
    Post count: 8

    I've discovered where to edit the plugin to make it do what I want. Starting at line 70 of frontend-dashboard.php I get the user's role with a function I've define in my functions.php file, checked it with the role that I would like to allow see all posts, and define the authors to display in the query. It looks something like this:

    	//find user role to display all or just current user posts
    	$role = get_user_role();
    		
    	if ($role == 'administrator') {
    		$author = -0;
    	} else {
    		$author = get_current_user_id();
    	}
    
            $args = array(
                'author' => $author,
                'post_status' => array('draft', 'future', 'pending', 'publish', 'private' ),
                'post_type' => $post_type,
                'posts_per_page' => wpuf_get_option( 'per_page', 'wpuf_dashboard', 10 ),
                'paged' => $pagenum
            );

    It's probably not a functionality that is requested often, but it would still be a nice addition to a future update for this plugin.

    Either way, great plugin! It works great and exceeded my expectations. Thanks guys!

    #5455

    Tareq Hasan
    Keymaster
    Post count: 2831

    As you are talking about the frontend dashboard, there is a way. WPUF gives you an filter wpuf_dashboard_query in the frontend dashboard. You could take advantage of the filter and modify the query as you need. Example:

    [php]
    function wpufe_regular_admin_dashboard( $args ) {

    $role = get_user_role();

    if ( $role == ‘administrator' ) {
    unset( $args[‘author'] );
    }

    return $args;
    }

    add_filter( ‘wpuf_dashboard_query', ‘wpufe_regular_admin_dashboard' );
    [/php]

    #5456

    springboard
    Participant
    Post count: 8

    Should I put that into the theme's functions.php file, so the plugin can still be updated in the future?

    #5457

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yeah, thats the idea behind action/filters!!

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘"Admin" Edit All Posts?’ is closed to new replies.