• Resolved lukashuggenberg

    (@lukashuggenberg)


    Hi Tobias

    is there a way to hide a Datatable button for logged-out users (I don’t want to let logged-out users download the table as an Excel sheet)?

    The DataTables Buttons and the Hide Columns/Rows from logged-out users TablePress Extensions are installed.

    Thanks,

    Lukas

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Yes, this is possible using some custom PHP code. For example, you could add this to the end of your theme’s “functions.php” file:

    add_filter( 'tablepress_table_render_options', 'lh_tablepress_buttons_only_logged_in_users', 10, 2 );
    function lh_tablepress_buttons_only_logged_in_users( $render_options, $table ) {
      if ( ! is_user_logged_in() ) {
        $render_options['datatables_buttons'] = '';
      }
      return $render_options;
    }

    Regards,
    Tobias

    Thread Starter lukashuggenberg

    (@lukashuggenberg)

    Hi Tobias,
    thank you very much for the fast reply.
    Works flawlessly – like anything you provide!
    Kind regards,
    Lukas

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘hide a Datatable button for logged-out users’ is closed to new replies.