Title: Filter
Last modified: August 21, 2016

---

# Filter

 *  Resolved [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/)
 * You showed me how to write a filter to wrap code around the table cells
    What
   I want to do is take a value from row1 and update row 3 with it This is the code
   I came up with but it does not work – do you know why?
 *     ```
       //***Custom TablePress Table 60**/
       add_filter( 'tablepress_cell_content', 'Table60', 10, 4 );
       function Table60( $tablepress_cell_content, $table_id, $row_number, $column_number )
           {
           if ($table_id==60)
               {
               if ($row_number!=1)
                   {
                   if ($column_number==1)
                       {
                       global $fernname;
                       $temp1=strip_tags($tablepress_cell_content);
                       $fernname=str_replace(" ","_",$temp1);
                       }
                   if ($column_number==3)
                       {
                       $tablepress_cell_content=$fernname;
                       }
                   }
               }
           return $tablepress_cell_content;
           }
       ```
   
 * _[Moderator Note: Please post code & markup between backticks or use the code
   button. Your posted code may now have been damaged by the forum’s parser.]_
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046078)
 * Hi Andrew,
 * thanks for your question, and sorry for the trouble.
 * You’ll just have to add `global $fernname;` in the second if-condition (for the
   3) as well (or move it to the top of the function).
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046088)
 * Ahhhh
    I nearly got there… Thanks It works now
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046094)
 * Ugh
    It is not working quite as I expected! You can see here: [http://ebps.org.uk/ferns-2/indentification/hectad-page-v2/](http://ebps.org.uk/ferns-2/indentification/hectad-page-v2/)
   I was expecting it to store the contents of column 1 and put it into column 3
   of the same row, but it seems to be putting the contents of column one from the
   next row into column 3?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046102)
 * Hi,
 * ah, yes… The reason or this is how the table is rendered. The rendering basically
   starts in the last row (because TablePress needs to check for keywords like `#
   rowspan#` and `#colspan#` from the bottom up.
 * The best approach here should therefore be to use a different filter hook, like`
   tablepress_table_render_data`, and loop through the table array there.
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046110)
 * where would I find the instructions for how to use this filter?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046113)
 * Hi,
 * that filter is defined in the class-render.php file, see [https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L251](https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L251)
 * You would register a function to that hook in the same way as with the `tablepress_cell_content`,
   like
 *     ```
       add_filter( 'tablepress_table_render_data', 'andrew_filter_table', 10, 3 );
       function andrew_filter_table( $table, $orig_table, $render_options ) {
         ...
         return $table;
       }
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046121)
 * I will look tomorrow
    For tonight I “swapped” column 3 to column 1 and column
   1 to column 2 This way it looks at column 2 before column 1 and it works OK!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046198)
 * Hi,
 * that’s also a nice trick. 🙂
    If there’s something else here where I can help,
   just let me know.
 * Best wishes,
    Tobias

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

The topic ‘Filter’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/filter-8/#post-5046198)
 * Status: resolved