We're Moving to a New Support Platform – Starting June 1st!
We’re excited to let you know that starting June 1st, we’ll be transitioning to a new support system that will be available directly on our product websites – Amelia, wpDataTables, and Report Builder. In fact, the new support platform is already live for Amelia and wpDataTables, and we encourage you to reach out to us there.
You'll always be able to reach us through a widget in the bottom right corner of each website, where you can ask questions, report issues, or simply get assistance.
While we still do not offer live support, a new advanced, AI-powered assistant, trained on our documentation, use cases, and real conversations with our team, is there to help with basic to intermediate questions in no time.
We're doing our best to make this transition smooth and hassle-free. After June 1st, this current support website will redirect you to the new "Contact Us" pages on our product sites.
Thanks for your continued support and trust – we’re excited to bring you an even better support experience!
Good morning!
First of all, datatables is TERRIFIC, just have to get that out of the way. So good job to you and your team.
Secondly, my problem. Is there a way in the wpdatatables plugin to hide columns based on what type of user is logged in? For instance, I have a few columns that contain sensitive data (personal phone number, personal address, etc.) that the general public should not see. Can I make these columns appear to only those who are logged in as a certain user role, such as "Editor"?
I know I can do this sort of thing with Javascript or php but I want to make sure that the wpdatatables plugin doesn't already have this feature built in. Also, if a separate script is what I will end up needing, do you already have a sample script I can go by to save me some time.
Thanks for all the help, you guys rock!
Hi chaddly,
Thank you for your purchase.
Thank you so much, we appreciate that.
Sorry for disappointment, but something like this is not possible with built in features of plugin. When you are using option "Users see and edit only own data" users will see only own data(but for hole row of table). It's not possible to hide columns based on login user.
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables
@chaddly,
I also wanted this feature so my workaround is to simply create different tables with different columns for different users. I then use custom functions in functions.php to select which table is visible depending on which user group is viewing (calling the table using do_shortcode). Anonymous users can see the reduced table without those sensitive columns. I created a full table for logged in users and duplicated it into a new table with some columns removed.
Hey Lethalmiko, that sounds like what I need! Any chance you can send me the function to to use as a template?
@chaddly,
Place this example code in your functions.php file in your currently activated theme. Edit as necessary to add or remove roles and put corresponding table numbers.
----------------------------------------------------------------------------
function display_table_by_role_shortcode() {
echo do_shortcode($table);$current_user = wp_get_current_user();
$user_role = $current_user->roles[0];
if($user_role == 'administrator')
{
$table = "[wpdatatable id=1 table_view=regular]"; //table with all columns
}
elseif($user_role == 'Editor')
{
$table = "[wpdatatable id=2 table_view=regular]"; //table with fewer columns
}
else
{
$table = "[wpdatatable id=3 table_view=regular]"; //table for everyone else including anonymous users
}
}
add_shortcode('display_table_by_role', 'display_table_by_role_shortcode');
----------------------------------------------------------------------------
You then put the shortcode in your page as follows:
----------------------------------------------------------------------------
[display_table_by_role]