Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Add and Change Position of User Menu */
- add_filter('jnews_dropdown_link', 'jeg_nav_account_menu', 1);
- function jeg_nav_account_menu($dropdown)
- {
- if (is_user_logged_in()) {
- /* If you need to get a list of roles */
- // global $wp_roles;
- // print("<pre>" . print_r($wp_roles->roles, true) . "</pre>");
- $roles = array('administrator', 'author', 'contributor'); /* Set Roles */
- $user = wp_get_current_user(); /* Get Role User */
- foreach ($roles as $role) {
- if (in_array($role, $user->roles)) {
- $temp = $dropdown;
- unset($dropdown);
- /* Set the position under this code. */
- $dropdown['new_menu'] = array( /* New Menu */
- 'text' => 'New Menu',
- 'url' => 'http://jnews.io'
- );
- $dropdown['account'] = true; /* Set Position of My Account || If not initialized or set to false, the position will always be at the top */
- $dropdown['new_menu2'] = array( /* New Menu 2 */
- 'text' => 'New Menu 2',
- 'url' => 'http://jnews.io'
- );
- $dropdown['logout'] = $temp['logout']; /* Set Position of logout || Don't delete this initialization, just move the position */
- /* Finish adjusting the Position */
- return $dropdown;
- }
- }
- return $dropdown;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement