pusselw
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [Groups] Not hide menu item but add [locked] to itI solved this by modifying wp_get_nav_menu_items in groups/lib/class-groups-post-access-php.
I modified it so it adds an <i> tag. If the page has restrictions but the user has access to it, it shows
<i class="unlocked"></i>and if the user doesen’t have access we add<i class="locked"></i>. If it’s a page witn no restrictions it doesen’t show anything.Here’s the code:
public static function wp_get_nav_menu_items( $items = null, $menu = null, $args = null ) { $result = array(); if ( apply_filters( 'groups_post_access_wp_get_nav_menu_items_apply', true, $items, $menu, $args ) ) { $user_id = get_current_user_id(); foreach ( $items as $item ) { // @todo might want to check $item->object and $item->type first, // for example these are 'page' and 'post_type' for a page if ( self::user_can_read_post( $item->object_id, $user_id ) ) { $group_ids = Groups_Post_Access::get_read_group_ids( $item->object_id ); if ( count( $group_ids ) > 0 ) { $item->title .= '<i class="unlocked"></i>'; } $result[] = $item; } else { $item->title .= '<i class="locked"></i>'; $result[] = $item; } } } else { $result = $items; } return $result; }- This reply was modified 7 years ago by pusselw. Reason: Formatting
Viewing 1 replies (of 1 total)