Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There are many plugins out there that let you order Pages and/or Posts with drag and drop.

Is there something similar to order users?

Or if not, is it possible to create a plugin for that (i.e. are there sufficient filters, actions etc. in place?

share|improve this question
1  
Please edit your question and explain in detail why do you need to order users? What's the purpose it will serve for you? –  Mayeenul Islam Sep 1 '13 at 16:58
    
@MayeenulIslam All the users on my site are also authors and I'd like to have them listed on a special page. And I'd like to be able to manually sort them. I hope that explanation might help... somehow... –  frnhr Sep 4 '13 at 7:01
    
Even if we can't close the question right now: It's off topic as it's a plugin recommendation. Please edit it to bring it on topic. The help center might be of help to achieve that. –  kaiser Sep 17 '13 at 14:54
1  
The "special page" listing authors you are talking about: are you looking for a frontend, public page that lists the authors? How many authors do you have? –  Ben Miller Sep 17 '13 at 21:00
    
if you want to use the shopping cart of drag and drop you can use ecwid for this its third party integration and have drag and drop facilities –  Vikas Gautam Sep 18 '13 at 8:48
add comment

2 Answers

Quite a specific feature, never seen any plugin. But it's a matter of taking a drag'n'drop plugin and adapting it.

Here, a stripped and adapted version of My Link Order.
Description and to-do:

  • A new submenu is created in Users, My Users Order.
  • In the plugin page, execute the function orderUsers() in your browser console, you'll see the current order as an array. Drag and drop and execute again, the array shows the new order.
  • You'll have to use the Settings API or create your AJAX code to deal with saving the order as User Meta data.
  • The styles and scripts printed within the submenu callback should go in their own CSS and JS files, and enqueued accordingly.
<?php
/* Plugin Name: My Users Order */

add_action( 'admin_menu', 'myuserorder_menu' );

function myuserorder_menu()
{    
    $page = add_users_page(
        __( 'My Users Order', 'myuserorder' ), 
        __( 'My Users Order', 'myuserorder' ), 
        'manage_links', 
        'myuserorder', 
        'myuserorder'
    );
    add_action( "admin_print_scripts-$page", 'myuserorder_js_libs' );
}

function myuserorder_js_libs() 
{
    wp_enqueue_script( 'jquery-ui-sortable', false, array( 'jquery-ui-core', 'jquery' ) );
}

function myuserorder()
{
    ?>
    <div class='wrap'>
        <form name="frmMyUserOrder" method="post" action="">
            <h2><?php _e('My Users Order', 'myuserorder') ?></h2>   
            <ul id="myUserOrderList">
            <?php
            $results = get_users();
            foreach( $results as $user )
                echo "<li id='{$user->data->ID}' class='lineitem'>" . $user->data->display_name . "</li>";
            ?>
            </ul>
        </form>
    </div>

    <style type="text/css">
        #myUserOrderList {
            width: 90%; 
            border:1px solid #B2B2B2; 
            margin:10px 10px 10px 0px;
            padding:5px 10px 5px 10px;
            list-style:none;
            background-color:#fff;
            -moz-border-radius:3px;
            -webkit-border-radius:3px;
        }
        li.lineitem {
            border:1px solid #B2B2B2;
            -moz-border-radius:3px;
            -webkit-border-radius:3px;
            background-color:#F1F1F1;
            color:#000;
            cursor:move;
            font-size:13px;
            margin-top:5px;
            margin-bottom:5px;
            padding: 2px 5px 2px 5px;
            height:1.5em;
            line-height:1.5em;
        }       
        .sortable-placeholder{ 
            border:1px dashed #B2B2B2;
            margin-top:5px;
            margin-bottom:5px; 
            padding: 2px 5px 2px 5px;
            height:1.5em;
            line-height:1.5em;  
        }
    </style>

    <script language="JavaScript" type="text/javascript">
        function orderUsers() 
        {
            var newOrder = jQuery("#myUserOrderList").sortable("toArray");
            console.log( newOrder );
        }
        function myuserorderaddloadevent()
        {
            jQuery("#myUserOrderList").sortable({ 
                placeholder: "sortable-placeholder", 
                revert: false,
                tolerance: "pointer" 
            });
        };
        addLoadEvent( myuserorderaddloadevent );
    </script>
    <?php
}
share|improve this answer
1  
Sweet concept - straight forward. +1 –  kaiser Sep 18 '13 at 21:22
add comment
up vote 0 down vote accepted

It seems there is no such plugin...

So I created my own: https://github.com/cek125i/simple-user-ordering
(~300 php lines, too long to post here)

Influenced a lot by "Simple Page Ordering" plugin, but created from scratch.

The lousy truth about this problem is that there seems to be no built-in way to sort users by meta-value. Luckily I have only 10-20 users so hopefully it won't be too performance-expensive to sort them manually after fetching (that means one additional query per user to fetch meta value).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.