Navigation überspringen

[Gelöst] Give logged in user access to Media Library but no other admin areas

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The Media Library pop up show but they can't do anything.

Solution:

You need to enable AJAX in the custom codes, for example:

	if($user_role === 'exhibitor' && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){

Relevant Documentation:

This support ticket is created vor 4 Jahre, 11 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 1 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von michaelR-26 vor 4 Jahre, 11 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#1689219
Annotation 2020-07-06 115236.png

On a previous ticket you helped me block user access to the admin area, unless they were an admin.

I now realize that users will need access to the media library to view and upload new media. I tried having Access control the Media LIbrary, but that did not work. The Media Library pop up show but they can't do anything. See attached screen shot.

Is there are way to modify the origional code you provided to accomplish this?

Here is the code:

function func_no_admin_access() {
$redirect = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : home_url( '/' );
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if($user_role === 'exhibitor'){
exit( wp_redirect( $redirect ) );
}
}
add_action( 'admin_init', 'func_no_admin_access', 100 );

#1690217

My issue is resolved now. Thank you!