Use hook tableon_profile_extend for it.
For this in file functions.php add next code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $profile['my_new_column'] = [ 'title' => TABLEON_Vocabulary::get('My new column'), 'order' => FALSE, 'action' => function($post_id) { return 'Hello World!'; } ]; } return $profile; }, 10, 2); |
Using $post_id you can create any data and return it directly to the cell.
Lets review more complicated example demonstrated here. Make your attention on button "Ask Me", click on it. As you can see this is contact form where customer can write a message to the site adminĀ about the post/product. To create it:
- create new page and select template as "TABLEONĀ Blank Page"
- install any contact form plugin, for example wpform
- place to new page content contact form shortcode, for example [wpforms id="641"]
- add next code to the functions.php file of the current WordPress theme:1234567891011121314151617181920add_action('tableon_profile_extend', function($profile, $action_name) {if ($action_name === 'tableon_default_tables') {$profile['ask_me'] = ['title' => 'Ask Me','order' => FALSE,'action' => function($post_id) {return TABLEON_HELPER::draw_html_item('a', ['href' => 'javascript: new Popup23({iframe:"https://demo.posts-table.com/wpform-contact-ask-me/?post_id=' . $post_id . '", '. 'allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture", '. 'title:"Ask manager about the post-product"});void(0);','class' => 'tableon-btn'], 'Ask Me');}];}return $profile;}, 10, 2);
Make your attention on the link "https://demo.posts-table.com/wpform-contact-ask-me" and change it to your own. - To fill some inputs of the contact form apply next code:12345678910111213141516add_filter('wp_footer', function() {if (is_page(642)) {if (isset($_GET['post_id'])) {$post = TABLEON_Default::get_post(intval($_GET['post_id']));if (is_object($post)) {?><script>document.getElementById('wpforms-641-field_4').value = '<?php echo addslashes($post->post_title) ?>';document.getElementById('wpforms-641-field_2').value = "Hello, give me please more information about the post: <?php echo addslashes($post->post_title) ?>!";</script><?php}}}});
642 - page ID where contact form placed;
wpforms-641-field_4 - ID of the input