WordPress get last inserted user id

I want to disable user_login field into my CMS. They are register only their email adress. I think to create secret user login by programmatically. I think for accessibility and manageability also I want to use their ID'.

For this I want to know last user's ID. I know the unprofessional way of doing this. A way as below,

    ?php
    $args = array(
        'orderby'      = 'registered',
        'order'        = 'DESC',
        'number'       = 1
    );

    $users = get_users($args);

    $last_user_registered_ID = $users[0]-ID;

But I was wondering if there is a more professional way. In addition to all this, I am always open to your criticism and different suggestions about the approach to this issue.

Topic wp-user-query wpdb php Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.