If Menu – Visibility control for Menu Items

Description

Contrôlez les éléments de menu que les visiteurs de votre site voient, en fonction de règles de visibilité. Voici quelques exemples :

  • Display a menu item only if User is logged in
  • Masquer les éléments de menu si le périphérique est un mobile
  • Display menu items for Admins and Editors
  • Masquer la connexion ou les liens d’abonnement pour les utilisateurs connectés
  • Afficher les éléments de menu pour les utilisateurs des États-Unis ou du Royaume-Uni
  • Display menu items only for Customers with active membership
  • Afficher les éléments de menu pour les visiteurs parcourant avec la langue anglais ou espagnol

The plugin is easy to use, each menu item will have a new option “Change menu item visibility” which will enable the selection of visibility rules (example in Screenshots).

Fonctionnalités

  • Basic set of visibility rules
    • User state User is logged in
    • User roles Admin Editor Author etc
    • Page type Front page Single page Single post
    • Is Archive page (year, category, search results, etc)
    • Le périphérique du visiteur est un Mobile
  • Advanced visibility rules – requires Premium plan
    • Visitor location – detect visitor’s Country
    • Visitor language – detect visitor’s selected Language
    • WooCommerce Subscriptions – Display menus for users with active subscription
    • WooCommerce Memberships – Display menus for customers with active membership plans
    • Groups – Detect if users are in specific groups
    • WishList Member – Detect the users’ membership level
    • Restrict Content Pro – Detect the users’ subscription level
  • Multiple rules – mix multiple rules for a menu item visibility
    • show if User is logged in AND Device is mobile
    • show if User is Admin AND Is front page
  • Support for adding your custom rules

Un exemple d’ajout d’une nouvelle règle de visibilité est décrit dans la FAQ.

Captures d’écran

  • If Menu website demo
  • Activer les règles de visibilité pour les éléments de menu
  • Exemple de règles de visibilité

FAQ

If Menu is broken, no visibility rules are available

There’s a known limitation with adding functionality for menu items in WordPress, and conflicts may happen between some plugins and themes.

If there are multiple plugins that extend Menu Items, for example If Menu and a plugin for Menu Icons, only one of them can add the needed functionality and the other one won’t work as expected.

Ce problème avec WordPress est en cours, il sera corrigé dans une prochaine version.

If the « Menus » page is blank or options for visibility rules are not displaying, there is a way to test which plugin/theme causes this conflict.
Please disable other plugins or themes until you find the one that causes the problem, and contact the respective developers.
In the message include the link to WordPress ticket about menu items https://core.trac.wordpress.org/ticket/18584 where they can see detailed info on how to fix the problem.

Changes to menus are not saved

This problem may happen on sites with a large number of menu items.
In most cases, this is not a limitation or problem caused by plugins or WordPress, but by the hosting server.

Your hosting provider or server limits the amount of data that can be sent to WordPress for saving in database.
The setting is named « PHP max_input_vars » and it’s value should be increased, ex: max_input_vars = 200 to max_input_vars = 500.
Contact your hosting provider or make the change yourself if you have access. More details can be found here https://core.trac.wordpress.org/ticket/14134

Comment puis-je ajouter une règle de visibilité personnalisée pour les éléments de menu ?

New rules can be added by any other plugin or theme.

Example of adding a new custom rule for displaying/hiding a menu item when current page is a custom-post-type.

// theme's functions.php or plugin file
add_filter('if_menu_conditions', 'my_new_menu_conditions');

function my_new_menu_conditions($conditions) {
  $conditions[] = array(
    'id'        =>  'single-my-custom-post-type',                       // unique ID for the rule
    'name'      =>  __('Single my-custom-post-type', 'i18n-domain'),    // name of the rule
    'condition' =>  function($item) {                                   // callback - must return Boolean
      return is_singular('my-custom-post-type');
    }
  );

  return $conditions;
}

Où puis-je trouver les fonctions conditionnelles ?

WordPress fournit beaucoup de fonctions qui peuvent être utilisées pour créer des règles personnalisées pour presque toutes les combinaisons imaginables par les développeurs de thèmes/extensions.

Avis

23 novembre 2021
Leads to extremely slow loading of CMS and web page upon activation. Looks like a lot of code is needed? The website seems to work normal after activation, but I do not take the chance to use this plugin.
15 novembre 2021
Plugin, including the premium version, doesn't work as advertised and there's NO support, no way of contacting anyone. Bad plugin, bad service.
26 septembre 2021
Has the plugin been abandoned? No updates in 8 months and no responses to support here. I think a recent WordPress update may have broken it. I now see a green eye icon above a menu item. There are other free plugins that do the same job, such as 'User Menus' from Code Atlantic.
20 avril 2021
Purchased this plugin to get advanced features. Didn't work, no word from support. Tried to reach out multiple ways and never heard back. No refund. Basically took my money for nothing, had to find another solution.
4 mars 2021
Congratulations, you get the dubious distinction of being my first review. I am reporting you to Plugins. For the people who do not know what "phone home" means, it means that this plugin sends information about your site to themselves without your permission.
Lire les 116 avis

Contributeurs & développeurs

« If Menu – Visibility control for Menu Items » est un logiciel libre. Les personnes suivantes ont contribué à cette extension.

Contributeurs

“If Menu – Visibility control for Menu Items” a été traduit dans 5 locales. Remerciez l’équipe de traduction pour ses contributions.

Traduisez « If Menu – Visibility control for Menu Items » dans votre langue.

Le développement vous intéresse ?

Parcourir le code, consulter le SVN dépôt, ou s’inscrire au journal de développement par RSS.

Journal

0.16.2 – 17 January 2020

  • Fixed – Error shown about the registered REST Api endpoint
  • Updated – Ensure compatibility with WordPress 5.6

0.16.1 – 11 April 2020

  • Fixed – Improved compatibility with other plugins that extend menu items

0.16 – 1 April 2020

  • Added – Visibility rule – Is Archive page
  • Updated – Ensure compatibility with WordPress 5.4
  • Updated – Improved compatibility with WooCommerce Membership/Subscription plugins

0.15 – 2 July 2019

  • Updated – Texts & styles for If Menu settings page
  • Fixed – PHP error that may appear for Visibility Rules saved before If Menu v0.9

0.14 – 2 May 2019

  • Added – « User registration is allowed » visibility rule
  • Updated – Improved support for setting multiple visibility rules, without eval function from PHP
  • Updated – Show Membership Levels from « WishList Member » plugin
  • Updated – Compatibility with WordPress 5.2

0.13 – 8 April 2019

  • Updated – Compatiblity with latest WordPress version
  • Updated – Texts & more info about Premium plan
  • Added – Visibility rule – User has expired Subscription, integration with Restrict Content Pro plugin
  • Updated – Visibility rule – Restrict Content Pro Membership shows Level number

0.12.2 – 3 September 2018

  • Fixed – PHP error blocking page load (function formatting language names)

0.12 – 3 September 2018

  • Added – Visiblity rule – Detect visitor’s selected language
  • Updated – Link to Support Request email
  • Fixed – Better check for Premium plan after purchase (was not enabled in some cases)

0.11 – 23 Jul 2018

  • Fixed – Blank page on « Appearance -> Menus »
  • Fixed – Better compatitility with themes / plugins

0.10 – 8 May 2018

  • Added – Visibility rule – User has Subscription Level, integration with Restrict Content Pro plugin
  • Fixed – Display all WooCommerce Membership plans and save the visibility rule
  • Fixed – Small render artifact in menu item title

0.9 – 21 April 2018

This version requires PHP version to be at least 5.4
* Added – Visibility rule – Customer has active membership, integration with WooCommerce Memberships plugin
* Added – Visibility rule – Customer has active Job Manager Listing Subscription, integration with Listing Payments for WP Job Manager plugin
* Added – Option to disable menu item filtering in Admin panel
* Updated – Texts and notices

0.8.3

Date de sortie – 22 février 2018

  • Fixed – Support for PHP <= 5.3, fixes error

0.8.2

Date de sortie – 20 février 2018

  • Fixed – Support for older visibilty rule names, fixes PHP warning

0.8.1

Date de sortie – 20 février 2018

  • Fixed – Better options checking, fixes PHP warning

0.8

Date de sortie – 19 février 2018

  • Added – Visibility rules with multiple options. Requires Premium plan
  • Added – Visibility rule – User country
  • Added – Visibility rule – Is Super Admin on MultiSite
  • Added – Visibility rule – User is in Group, integration with Groups plugin
  • Added – Visibility rule – User has subscription, integration with WooCommerce Subscriptions plugin
  • Added – Visibility rule – User has active membership plan, integration with WooCommerce Memberships plugin
  • Added – Visibility rule – User membership level, integration with WishList Member plugin
  • Updated – Better conflict detection for Nav_Menu Walker
  • Fixed – translation strings & function used

0.7

Date de sortie – 18 septembre 2017

  • Enhancement – Nicer styling for visibility rules
  • Added – Peek option – Let admins preview hidden menu items
  • Ajouté – Page des réglages

0.6.3

Date de sortie – 17 août 2017

  • New visibility rule – Language Is RTL
  • Fix – Single rule works on servers with Eval disabled

0.6.2

Date de sortie – 8 août 2017

  • Fix – Backwards compatibility with PHP < 5.4

0.6.1

Date de sortie – 7 août 2017

  • Improvement – Change labels & texts for easier use
  • Improvement – Better compatibility with latest versions of WordPress
  • Improvement – Better compatibility with translation plugins
  • Fix – Detection for conflict with other plugins

0.6

Date de sortie – 27 août 2016

  • Improvement – Dynamic conditions based on default & custom user roles (added by plugins or themes) thanks Daniele
  • Improvement – Grouped conditions by User, Page or other types
  • Fix – Filter menu items in admin section
  • Fix – Better menu items filter saving code

0.5

Release Date – 20 August 2016

  • Improvement – Support for WordPress 4.6
  • Feature – New condition checking logged in user for current site in Multi Site [requested here](https://wordpress.org/support/topic/multi-site-user-is-logged-in-conditi
    on)
  • Fonction – Prise en charge de plusieurs conditions merci pour cette idée
  • Improvement – RO & DE translations

0.4.1

Release Date – 13 December 2015

  • Fix – Fixes issue with adding new menu items

0.4

Release Date – 29 November 2015

0.3

  • Plugin icon
  • Set as compatible with WordPress 4

0.2.1

corrections mineures

  • Fix – Editing menus – show/hide conditions when adding new item (thanks Joseph Segal)

0.2

Mise à jour pour la compatibilité avec les nouvelles versions de WordPress

  • Feature – access to menu item object in condition callback (thanks BramNL)
  • Fix – alert for leaving page even if no changes were made for menus (thanks Denny)
  • Fix – update method in Walker_Nav_Menu_Edit to be compatible with newer version of WP
  • Fix – example in Readme (thanks BramNL)

0.1

  • Plugin release. Included basic menu conditional statements