• Resolved esinformatica

    (@esinformatica)


    Is it possible to sort the user group by alphabetical order and not creation order in to the group selection ?

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

    (@helgatheviking)

    The roles listed by NMR are a filterable multidimensional array, so you could try something like this in your theme’s functions.php:

    
    /*
     * Sort the NMR roles
     * @param: $roles an array of all available roles with ID=>Name
     * @return: array
     */
    function kia_sort_roles( $roles ){
    	if( is_admin() ) {
    		$array_lowercase = array_map( 'strtolower', $roles );
    		array_multisort( $array_lowercase, SORT_ASC, SORT_STRING, $roles );
    		return $roles;
    	}
    }
    add_filter( 'nav_menu_roles', 'kia_sort_roles' );
    

    Keep in mind that NMR displays the roles left to right before starting a new line.

    So the roles will come out like:

    A B C D
    E F G H

    and not

    A D
    B E
    C F

    I hope that helps!

    Thread Starter esinformatica

    (@esinformatica)

    Wow! It worked right away!
    Thank you very much for your help

    Plugin Author HelgaTheViking

    (@helgatheviking)

    You’re welcome! I’m glad it worked. I probably ought to display them that way by default.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort User Group by Alphabetical order’ is closed to new replies.