Site icon Hip-Hop Website Design and Development

WordPress action admin_post for non-admin authenticated users – Form submission

I’m trying to submit form using:

`admin_post` && `admin_post_nopriv` 

actions.
This is a shortcode for users search:

add_shortcode( 'search_users', 'search_users' );
function search_users( $atts ,$content = null ) {
ob_start();?>
<div class="search-box-main-container">
    <form method="POST" id="sul-searchform" action="<?php echo home_url() . '/wp-admin/admin-post.php' ?>" class="search-form">
        <div class="search-box-container">
            <input type="text" class="search-box" name="search" id="sul-s"/>
        </div>

        <div class="submit-container">
            <input type="hidden" name="action" value="search_users_action">
            <input type="submit" class="search-box-submit" name="submit" id="sul-searchsubmit"
                   value="Search"/>
        </div>
    </form>
</div>

<?php
$output = ob_get_contents();
ob_end_clean();
return  $output;
}

And these are the actions:

add_action( 'admin_post_search_users_action', 'list_users' );
add_action( 'admin_post_nopriv_search_users_action', 'list_users' );
function list_users() {
$search = (isset($_POST['search'])) ?sanitize_text_field($_POST['search']) : false;
wp_redirect( home_url() . '/user-listing?search=' . $search );
}

They work only for admin users and unauthenticated users. With authenticated non-admin user, the actions haven’t been called. It just redirects to the home page!

Is there another action to handle authenticated non-admin users?