Changing Admin Menu based on Event
-
Hello everyone i hope i post this in the right place,
First a short overview of what im trying to do:
Im creating a WordPress Homepage for a few friends. Not all of them are very good with computers so I would like to alter the Admin Menu (in Dashboard), to add an “Expertmode”.
Per defaul I would not show most of the Admin Menu. And after clicking the “Expertmode” it should show the full Admin Menu.What I did so far (gonna use one example to simplify the problem):
I did everything in the functions.php of my child theme (just for easy testing)global $expertmode; $expertmode = false; if (!$Expertenmodus): function remove_menu_pages_for_non_experts(){ if ( current_user_can( 'manage_options' ) ) { remove_menu_page( 'edit.php?post_type=page' ); //Pages remove_menu_page( 'themes.php' ); //Appearance } } endif; //Call the Function add_action( 'admin_menu', 'remove_menu_pages_for_non_experts' );
That removes all of the mentioned AdminMenus.
Adding a new AdminMenu for the expertmode and a checkbox to activate the expertmode:
// Function for the output on the expertmode page function expertmode_output (){ echo '<body> <h1>Expertenmodus</h1> <p>Click the Checkbox for ExpertMode</p><br /> <input type="checkbox" value="expertmode" name="ch[]" id="expertmode"/><label for="expertmode">expertmode</a> </body>'; } if ($_POST['expertmode'] == 'expertmode'): $expertmode = true; endif;
The problem i encounter:
– Since the variable ($expertmode) is changed after the function, it has no effect at all
Is there a way to do this, so that expertmode stays activated until you log out?
And how could i make it work that the checkbox actually changes the Admin menu?My coding experience is limited, and I only started with WordPress a few days ago.
Thanks in advance for any help.
- The topic ‘Changing Admin Menu based on Event’ is closed to new replies.