• Resolved korash

    (@korash)


    Hi,

    I have just installed TablePress to implement a table which can include user data such as first name, last name, and work position etc…

    I have just tried to use php code as shown below, but it doesn’t work.

    <?php $user_info = get_userdata(1);
    echo ‘Username: ‘ . $user_info->user_login . “\n”;
    echo ‘User level: ‘ . $user_info->user_level . “\n”;
    echo ‘User ID: ‘ . $user_info->ID . “\n”;
    ?>

    I think there should be an easy way of doing this be taking advantage of all nice TablePress features.

    Thanks.

    Terry Ahn

    http://wordpress.org/extend/plugins/tablepress/

Viewing 1 replies (of 1 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question.

    The reason for this is that PHP code does not work in table cells by default. You can however enable PHP in table cells by installing a small “TablePress Extension” (see https://github.com/TobiasBg/TablePress-Extensions/blob/master/tablepress-php-in-tables/tablepress-php-in-tables.php ).

    However, I’m not really sure that the approach of using TablePress for this a good one. Unless you really need an editable table, it might be easier to just use PHP (for example in a WordPress Page Template) to print the HTML code for a table, filled with your user data, to the page. You could then (if you want this) add the sorting/filter/pagination features, by manually loading the DataTables JavaScript library from http://www.datatables.net (which is the same JS library that TablePress uses for these features) into the page.

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘How to retrieve usermeta data or userdata into table?’ is closed to new replies.