"Admin" Edit All Posts?

This topic contains 6 reply and 3 voices, and was last updated by Tareq Hasan 10 years, 10 months ago
Viewing 6 Posts - 1 through 6 (of 6 total)
Author Posts
June 28, 2013 at 6:59 pm 5394
Tareq Hasan 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!
July 1, 2013 at 3:42 am 5435
Mahi Mahi

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 ?

July 1, 2013 at 4:50 am 5439
springboard springboard

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?

July 1, 2013 at 2:38 pm 5451
springboard springboard

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!

July 1, 2013 at 3:39 pm 5455
Tareq Hasan Tareq Hasan

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]

July 1, 2013 at 3:42 pm 5456
springboard springboard

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

July 1, 2013 at 3:43 pm 5457
Tareq Hasan Tareq Hasan

Yeah, thats the idea behind action/filters!!

Viewing 6 Posts - 1 through 6 (of 6 total)