Accordions – Access

Ticket for: Accordions
0
Accordions - Access 1
Harry Würgler
Nov 04, 2024 06:08 AM 2 Answers
Member Since Jan 1970
Unsolved Solved Mark as Solved Mark as Unsolved
Subscribed Subscribe Not subscribe
Flag(0)

Hello
I have problems with the authorization.
Besides the administrator, I have two main roles. The editor and the Zettel. The Zettel should only be able to access the accordion and make changes there. He does not have to create or ... It is only about customizations. It's the same with the editor.
I have tried to make additions in functions.php so that this works but I can't do it. On the one hand I have problems with the authorization for the Zettel and on the other hand the accordion is not displayed for the editor. What do I have to adjust in the following code so that it works.

 

// 4. Accordion-Menü für Zettel und Redakteur hinzufügen, falls es nicht automatisch angezeigt wird

function add_accordion_menu_for_zettel() {

if (current_user_can('zettel') || current_user_can('editor')) {

add_menu_page(

'All Accordions',

'Accordions',

'manage_options',               // ÄNDERUNG: Berechtigung auf "manage_options" gesetzt

'edit.php?post_type=accordions',

'',

'dashicons-admin-generic',

5

);

}

}

add_action('admin_menu', 'add_accordion_menu_for_zettel', 5);

 

// 5. Admin-Menü für Zettel und Redakteur einschränken, sodass nur das Accordion-Plugin sichtbar ist

function restrict_admin_menu_for_zettel() {

if (current_user_can('zettel') || current_user_can('editor')) {

remove_menu_page('index.php'); // Dashboard

remove_menu_page('upload.php'); // Media

remove_menu_page('edit.php'); // Posts

remove_menu_page('edit-comments.php'); // Comments

remove_menu_page('edit.php?post_type=page'); // Seiten

remove_menu_page('themes.php'); // Appearance

remove_menu_page('plugins.php'); // Plugins

remove_menu_page('users.php'); // Users

remove_menu_page('tools.php'); // Tools

remove_menu_page('options-general.php'); // Settings

remove_menu_page('wpcf7'); // Contact Form 7, falls aktiv

 

global $submenu;

foreach ($submenu as $key => $value) {

if ($key !== 'edit.php?post_type=accordions') {

unset($submenu[$key]);

}

}

}

}

add_action('admin_menu', 'restrict_admin_menu_for_zettel', 999);

 

// 6. Benötigte Berechtigungen nur für Accordions hinzufügen

function add_custom_capabilities() {

$roles = array('zettel', 'editor');

 

foreach ($roles as $role_name) {

$role = get_role($role_name);

if ($role) {

// Berechtigungen für Accordions

$role->add_cap('edit_accordions');             // Bearbeiten von Accordions

$role->add_cap('publish_accordions');          // Veröffentlichen von Accordions

$role->add_cap('read_private_accordions');     // Private Accordions lesen

$role->add_cap('delete_accordions');           // Löschen von Accordions

$role->add_cap('edit_others_accordions');      // Andere Accordions bearbeiten

$role->add_cap('delete_others_accordions');    // Andere Accordions löschen

$role->add_cap('edit_private_accordions');     // Private Accordions bearbeiten

$role->add_cap('edit_published_accordions');   // Veröffentlichten Accordions bearbeiten

$role->add_cap('delete_published_accordions'); // Veröffentlichten Accordions löschen

$role->add_cap('manage_options');              // ÄNDERUNG: "manage_options" Berechtigung hinzugefügt

}

}

}

add_action('init', 'add_custom_capabilities');

 

I am looking forward to your feedback and will be happy to answer any questions you may have.
Best regards

Harry Würgler
(Switzerland)

0 Subscribers
Submit Answer
Please login to submit answer.
2 Answers
Sort By:
Best Answer
0
Accordions - Access 2
Azizul Raju
Nov 19, 2024
Flag(0)

Hi, It's working on our end. Plz watch this youtube video - https://youtu.be/j2nlvJWam-Q?si=hw8DsUZD2YdHao1D

Sign in to Reply
Replying as Submit
Best Answer
0
Accordions - Access 2
Azizul Raju
Nov 11, 2024
Flag(0)

Hi, We apologize for taking too much time to fix this issue. Our team is working on it, and hopefully, we'll release the update today. Thank you for your patience.

Sign in to Reply
Replying as Submit