Kanca kullan tableon_profile_extend bunun için.
Bunun için dosyada functions.php sonraki kodu ekle:
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); |
$ Post_id kullanarak herhangi bir veri oluşturabilir ve doğrudan hücreye döndürebilirsiniz.
Daha karmaşık gözden geçirelim burada gösterilen örnek. Dikkatinizi düğmeden çekin "Bana sor"tıklayın. Gördüğünüz gibi bu, müşterinin gönderi / ürün hakkında site yöneticisine mesaj yazabileceği iletişim formudur. Oluşturmak için:
- yeni sayfa oluşturun ve şablonu seçin "TABLO Boş Sayfa"
- herhangi bir iletişim formu eklentisini yükleyin, örneğin wpform
- yeni sayfa içeriğine yer iletişim formu kısa kodu, örneğin [wpforms id = "641"]
- sonraki kodu şuraya ekle: functions.php mevcut WordPress temasının dosyası:
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);
Dikkatinizi bağlantıya çekin "https://demo.posts-table.com/wpform-contact-ask-me"ve kendi başınıza değiştirin. - İletişim formunun bazı girişlerini doldurmak için sonraki kodu uygulayın:
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 - iletişim formunun yerleştirildiği sayfa kimliği;
wpforms-641-field_4 - Giriş kimliği