最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Creating permissions rules with ACF repeater field

programmeradmin0浏览0评论

I'm trying to create a set of permission rules for a custom post type depending on user infos but I don't see how to wp query my posts with theses infos.

I've created a repeater field which allow me to select:

  • The user_meta key
  • The comparison operator (AND or OR)
  • The value of the user_meta key

Here is a screenshot to show you how I've done it: The main box is for OR permissions and each box in it for AND permissions.

Now I wanted to query my posts if the rules matched or if there is the repeater field is empty but I can't get my head around it...

Here is an exemple of what the repeater field returns:

Array
(
  [0] => Array
  (
    [ressource_regles_et] => Array
    (
      [0] => Array
      (
        [ressource_permission_name] => le-centre
        [ressource_permission_rule] => is
        [ressource_permission_value_fonction] => Array
          (
          )

        [ressource_permission_value_service] => Array
          (
          )

        [ressource_permission_value_centre] => baudricourt
      )

      [1] => Array
      (
        [ressource_permission_name] => le-centre
        [ressource_permission_rule] => is
        [ressource_permission_value_fonction] => Array
          (
          )

        [ressource_permission_value_service] => Array
          (
          )

        [ressource_permission_value_centre] => curial
      )

    )

  )

  [1] => Array
  (
    [ressource_regles_et] => Array
    (
      [0] => Array
      (
        [ressource_permission_name] => la-fonction
        [ressource_permission_rule] => is-not
        [ressource_permission_value_fonction] => president-e
        [ressource_permission_value_service] => Array
          (
          )

        [ressource_permission_value_centre] => Array
          (
          )

      )

    )

  )

)

Each key indexed first level array is for an OR permission and each array inside [ressource_regles_et] is for and AND permission.

Now I know how to apply my rules after having queried all the posts but I'd like to get the rules in WP_Query so that I can use Wordpress builtin pagination system.

Any ideas on how to you would do this?

Thanks for your help!

发布评论

评论列表(0)

  1. 暂无评论