Create an user listing using views?

Support MB Views Create an user listing using views?Resolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28589
    pixluserpixluser
    Participant

    Hello,

    I would like to know how to create an user listing using the views.

    This tutorial is very good for that : https://metabox.io/display-user-list-on-the-frontend-with-meta-box/

    But maybe a bit complex for a non php guy… (Also I'm using oxygen builder, so no templates, maybe I'm able to do that into a code block). But I would like to make it simple with views.

    How to loop the user's loop with the views?

    #28620
    Long NguyenLong Nguyen
    Moderator

    Hi,

    To get users in View, you can use the WordPress function get_users() and follow the documentation to know how to run a PHP function via the proxy mb
    https://docs.metabox.io/extensions/mb-views/#running-php-functions

    Here is the example code:

    {% set args = { meta_key: "publish_account", meta_value: "yes" } %}
    {% set users = mb.get_users( args ) %}
    
    {% for user in users %}
        {% set user_id = user.ID %}
        <tr>
            <td>{{ user.display_name }}</td>
            <td>{{ mb.rwmb_meta( 'position', {object_type: 'user' }, user_id ) }}</td>                
        </tr>
    {% endfor %}
    #28639
    pixluserpixluser
    Participant

    Hello Long Nguyen, thanks a lot, that's what I needed thanks.

    I think that it could be usefull for the MB views users to get a new component in views :

    "the user loop".

    to get this :

    {% set users = mb.get_users( args ) %}

    {% for user in users %}
    {% set user_id = user.ID %}
    {% endfor %}

    #28665
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for your feedback.

    I will inform the development team to add the user loop to Insert Field items.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.