Support » Plugin: New User Approve » user status filter not working

  • Resolved lalitavalon

    (@lalitavalon)


    Hello
    I used this pugin for my website. In my website there is a user registration. So some of the users are in pending, denied or in approved when I apply the filter in the user results so it will not filter the users .

    Please let me know what is the exactly the issue

Viewing 4 replies - 1 through 4 (of 4 total)
  • intelligencebank

    (@intelligencebank)

    Hi, I’m encountering the same issue. Filter option always return 0 results.

    phpstar

    (@phpstar)

    i have the same problem, my filter option always returns all user.
    If anyone solve this please tell us how do slove this issue

    phpstar

    (@phpstar)

    i have solved my problem, below i m explaining whats the problem in my case, may be it helps you to solve your problem

    ok, for me the problem is in plugin file name as “user-list.php” and below is the file path:
    “new-user-approve/includes/user-list.php”

    The first issue is in line 165 under this function i.e “function status_filter( $which )”
    In this line i.e “165” $which doesn’t have any value, so i comment the original line and modify it as follows:
    //$id = ‘new_user_approve_filter-‘ . $which; /* this is original */
    $id = ‘new_user_approve_filter-top’; /* this is my modified line */

    The next issue for me then is i didn’t get dropdown list of statusses like pendind,approve or denied,
    I solved this issue by just implement not condition in same function as above i.e “function status_filter( $which )” on line 175. below is the sample of code i modified
    <?php if ( count( $users ) ) : ?> /* original code */
    <?php if ( !count( $users ) ) : ?> /* My code with ! condition */

    Now the last issue i get is when filtering it always returns 0, and this issue is caused because of the bad coding of the author of this plugin.
    This issue caused because in same file i.e “user-list.php” there is a query function name as “function filter_by_status( $query )” on line 196, and this function has queries to filter results according to the selected status and in this function the author uses static table prefix value i.e wp_. this is very big mistake. I requested the autor to please solve this problem for future.
    Solution: This problem is solved by just replacing wp_ in this function by the prefix you have used in your plugin
    For example: i have my database tables with prefix tia_, so i changes the prefix wp_ in this function with tia_ and then plugin works great.
    Below is the original code and my code after changing the wp_ with tia_
    /* original code */
    public function filter_by_status( $query ) {
    global $wpdb;

    if ( !is_admin() ) {
    return;
    }

    $screen = get_current_screen();
    if ( isset( $screen ) && ‘users’ != $screen->id ) {
    return;
    }

    if ( $this->selected_status() != null ) {
    $filter = $this->selected_status();

    $query->query_from .= ” INNER JOIN {$wpdb->usermeta} ON ( {$wpdb->users}.ID = wp_usermeta.user_id )”;

    if ( ‘approved’ == $filter ) {
    $query->query_fields = “DISTINCT SQL_CALC_FOUND_ROWS {$wpdb->users}.ID”;
    $query->query_from .= ” LEFT JOIN {$wpdb->usermeta} AS mt1 ON ({$wpdb->users}.ID = mt1.user_id AND mt1.meta_key = ‘pw_user_status’)”;
    $query->query_where .= ” AND ( ( wp_usermeta.meta_key = ‘pw_user_status’ AND CAST(wp_usermeta.meta_value AS CHAR) = ‘approved’ ) OR mt1.user_id IS NULL )”;
    } else {
    $query->query_where .= ” AND ( (wp_usermeta.meta_key = ‘pw_user_status’ AND CAST(wp_usermeta.meta_value AS CHAR) = ‘{$filter}’) )”;
    }
    }
    }
    /* end of original code */

    /*my code */
    public function filter_by_status( $query ) {
    global $wpdb;

    if ( !is_admin() ) {
    return;
    }

    $screen = get_current_screen();
    if ( isset( $screen ) && ‘users’ != $screen->id ) {
    return;
    }

    if ( $this->selected_status() != null ) {
    $filter = $this->selected_status();

    $query->query_from .= ” INNER JOIN {$wpdb->usermeta} ON ( {$wpdb->users}.ID = tia_usermeta.user_id )”;

    if ( ‘approved’ == $filter ) {
    $query->query_fields = “DISTINCT SQL_CALC_FOUND_ROWS {$wpdb->users}.ID”;
    $query->query_from .= ” LEFT JOIN {$wpdb->usermeta} AS mt1 ON ({$wpdb->users}.ID = mt1.user_id AND mt1.meta_key = ‘pw_user_status’)”;
    $query->query_where .= ” AND ( ( tia_usermeta.meta_key = ‘pw_user_status’ AND CAST(tia_usermeta.meta_value AS CHAR) = ‘approved’ ) OR mt1.user_id IS NULL )”;
    } else {
    $query->query_where .= ” AND ( (tia_usermeta.meta_key = ‘pw_user_status’ AND CAST(tia_usermeta.meta_value AS CHAR) = ‘{$filter}’) )”;
    }
    }
    }
    /* end of my code */
    All the issue in in file user-lists.php

    Hope this answer helps you guys

    Plugin Author Josh Harrison

    (@picklewagon)

    This has been fixed in version 1.7.5 of the plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘user status filter not working’ is closed to new replies.