Hide by User Role from CubePoints Manage Table

http://wordpress.org/plugins/cubepoints/

I know this is not a WPMU Dev plugin or something natively available, but hopefully, someone can help me!

I want to modify the CubePoints plugin to not show users with a certain user role in the table of the "Manage" section of the CubePoints' dashboard.

I'm okay making a core change to the plugin if someone can lead me through this. Please respond ASAP. Thanks in advance!

  • signed_up
    • The Crimson Coder

    Here's a screenshot of the "Manage" page from CubePoints menu in Admin Dashboard. Basically, I want to hide all users with "contributor" user role from the table in the image. Or hide about 20 users based on their User ID or username?

    Whichever is easier? Please respond as soon as possible. Thanks in advance!

  • signed_up
    • The Crimson Coder

    @Patrick Cohen
    I will post it, but the only issue is the CubePoints support on wordpress.org forums is extremely slow and provided by other users only (not plugin author).

    As it says on the plugin page, http://cubepoints.com/forums should be used for all support and help with plugin, but the entire cubepoints.com domain is currently down and has been like that for couple of weeks.

    It would really be appreciated if you could flag/tag someone who may be able to help me with this (if you can't)? This is a rather urgent issue (because I'm implementing something for someone soon). Please respond as soon as possible. Thanks in advance.

  • Vaughan
    • Support/SLS MockingJay

    hiya

    by the looks of it, it gets the data using a simple sql query.

    $results = $wpdb->get_results("SELECT * FROM ".$wpdb->users." ORDER BY user_login ASC");

    but the capability is in the usermeta table. try this

    SELECT users.*
        FROM $wpdb->users users, $wpdb->usermeta usermeta
        WHERE users.ID = usermeta.user_id
        AND usermeta.meta_key LIKE '%capabilities'
        AND usermeta.meta_value NOT LIKE '%contributor%'
        ORDER BY users.user_login ASC

    dunno if that will work. but the file you need to edit is cp_admin_manage.php

    hope this helps

  • signed_up
    • The Crimson Coder

    @Vaughan

    SELECT users.*
        FROM $wpdb->users users, $wpdb->usermeta usermeta
        WHERE users.ID = usermeta.user_id
        AND usermeta.meta_key LIKE '%capabilities'
        AND usermeta.meta_value NOT LIKE '%contributor%'
        ORDER BY users.user_login ASC

    Should I just enter this at the top of "cp_admin_manage.php"? Also, contributor was just an example user role. If I have a custom user role setup (via User Role Editor), would I just enter %bob% (if "bob" was name of custom user role) instead of %contributor%?

    Respond ASAP! Thanks in advance!

  • Vaughan
    • Support/SLS MockingJay

    hiya

    find this line in that file

    $results = $wpdb->get_results("SELECT * FROM ".$wpdb->users." ORDER BY user_login ASC");

    it's near the top. you can't miss it

    then replace with

    $results = $wpdb->get_results("SELECT users.*
        FROM ".$wpdb->users." users, ".$wpdb->usermeta." usermeta
        WHERE users.ID = usermeta.user_id
        AND usermeta.meta_key LIKE '%capabilities'
        AND usermeta.meta_value NOT LIKE '%contributor%'
        ORDER BY users.user_login ASC");

    i don't know if user_roles editor saves the capabilities the same in the meta table. but if it does, then yes, it's as simple as changing to %bob%

    hope this helps

  • Vaughan
    • Support/SLS MockingJay

    hiya

    just add an OR in the query like this

    $results = $wpdb->get_results("SELECT users.*
        FROM ".$wpdb->users." users, ".$wpdb->usermeta." usermeta
        WHERE users.ID = usermeta.user_id
        AND usermeta.meta_key LIKE '%capabilities'
        AND usermeta.meta_value NOT LIKE '%contributor%'
        OR usermeta.meta_value NOT LIKE '%administrator%'
        ORDER BY users.user_login ASC");

    i think that should work

  • signed_up
    • The Crimson Coder

    @Vaughan
    I only have one %bob% user and one %administrator% user. I don't know why this is happening, but whenever I add the extra line that's supposed to hide administrator...

    my list went crazy with like 80 %bob% users, %30% administrators, and like 10 %usernothidden% users. Don't ask me why this has happened. Do you know how to fix this?

    UPDATE: I removed the code for now, but whenever I add it... the issue described above happens again.

  • Vaughan
    • Support/SLS MockingJay

    hiya

    yeah, you can slap me for that. try AND instead of OR

    $results = $wpdb->get_results("SELECT users.*
        FROM ".$wpdb->users." users, ".$wpdb->usermeta." usermeta
        WHERE users.ID = usermeta.user_id
        AND usermeta.meta_key LIKE '%capabilities'
        AND usermeta.meta_value NOT LIKE '%bob%'
        AND usermeta.meta_value NOT LIKE '%administrator%'
        ORDER BY users.user_login ASC");

    hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.