Filter hook to manage setting options for customer pages IDs

    • paolospag
      Participant
      # il y a 2 années et 8 mois

      Hello, is there a filter hook or any other method to manage plugin setting options?

      In particular, I want to programatically change customer pages IDs for different users: for example to show a different Dashboard page based on certain user IDs.

      I tried with this hook:

      cuar/core/settings/default-options

      but it doesn’t seem to fire in any way.

      I tried also with the WordPress core hook:

      option_{$option}

      using the cuar_options array to set a new one but it doesn’t work.

      Any suggestion?

      Thank you

    • Vincent Mimoun-Prat
      Maître des clés
      # il y a 2 années et 8 mois

      Hi,

      That aspect of the plugin is managed in the file customer-pages-addon.class.php : https://gitlab.com/wp-customerarea/plugins/customer-area/-/blob/master/src/php/core-addons/customer-pages/customer-pages-addon.class.php

      We will accept a pull request to add filters you may need to be added in order to do that.

      May I ask what goal you are trying to achieve? Support for WPML or multilang plugins?

    • paolospag
      Participant
      # il y a 2 années et 8 mois

      Hi Vincent,
      thank you for your answer.

      At the moment we need to show different versions of the “Dashboard” page based on the user’s role because within it we show different text in addition to the [customer-area-dashboard /] shortcode.

      But we don’t exclude that in the future we may want to show different pages even in a different language via WPML.

      I’m not sure, it would probably be enough to have a filter hook in the get_page_id function:
      https://gitlab.com/wp-customerarea/plugins/customer-area/-/blob/master/src/php/core-addons/customer-pages/customer-pages-addon.class.php#L199-L218

      Is there already a way to alter this behavior?

    • Vincent Mimoun-Prat
      Maître des clés
      # il y a 2 années et 8 mois

      Hi,

      I have a different approach that could be slightly easier I think: override the template file which displays the dashboard and stuff in there some conditional code based on the user role to include some custom HTML or even a custom post type of your own which would allow that content to be customizable easily.

      The template system documentation explains that quite well but do not hesitate to ask if you do not get something.

      Is there already a way to alter this behaviour?

      Currently not, but as I said, modify the main plugin by adding your own hooks where needed, test it and once you have all the modifications you need, just submit a merge request in the plugin repository, I will review it and include that in the plugin in the next version.

Vous lisez 3 fils de discussion

You must be logged in to reply to this topic.