wordpress php drag and drop

<?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
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source