• Resolved hosseinhpr1364

    (@hosseinhpr1364)


    hi Akira
    1. How can I use “search”, “search_columns”, “compare” and “value,field” parameters in “users loop”?

    2. May I use “if” statement in “user loop”? How?

    3. How can I exhibit desired/special users? such as a country’s users or a city ones?

    4. Is it possible to make a “pageNavi” for users? For example we have 20 users in one layar and the next 20 users in another layer…

    Please help me and explain and clarify the answers with examples.
    I’m creating “custom fild” using “user meta” plugin
    thanks

    https://ww.wp.xz.cn/plugins/custom-content-shortcode/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    Hello,

    1. The field and value parameters (and optionally compare) are used to display users who have specific value(s) in the specified field. For example..

    All users from Germany
    
    [users field="country" value="Germany"]
      Name: [user]
    [/users]

    The compare parameter can be used for more complex queries.

    Users not from NY or Boston
    
    [users field="city" value="New York, Boston" compare="not in"]
      Name: [user]
    [/users]
    
    Users over 18 years old
    
    [users field="age" value="18" compare=">"]
      Name: [user]
    [/users]

    The search parameter is used for keyword search:

    Users with matching keyword
    
    [users search="troll"]
      Name: [user]
    [/users]

    In addition, you can set the search_columns parameter to limit the keyword search to specific default field:

    Users with matching keyword in specific field
    
    [users search="troll" search_columns="email"]
      Name: [user]
    [/users]

    For details, please refer to the documentation under Settings -> Custom Content -> User. If you want to dig deeper, the [users] shortcode is based on WP_User_Query, and uses many of the same parameters.

    Plugin Author Eliot Akira

    (@miyarakira)

    2. Yes, there is a basic if statement for users loop, to filter users by field value.

    Display all users, with conditional content based on field value
    
    [users]
      Name: [user]
      [if user_field="country" value="Japan"]
        こんにちは!
      [/if]
    [/users]

    You can also use [if user_field] outside the users loop, in which case it will check the current user’s fields.

    3. With the [users] shortcode, you can use field and value parameters to display groups of users by field value, as seen in #1.

    4. Currently, pagination is not supported. Many people have requested this feature, so I’m planning to implement it — when I can find the time to do it right.

    Thread Starter hosseinhpr1364

    (@hosseinhpr1364)

    thanks you dear akira

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘user loop’ is closed to new replies.