Title: using after_row callback function
Last modified: August 31, 2016

---

# using after_row callback function

 *  Resolved [Arash65](https://wordpress.org/support/users/pershianix/)
 * (@pershianix)
 * [10 years ago](https://wordpress.org/support/topic/using-after_row-callback-function/)
 * Hello and thanks a lot for your absolutely great plugin!
 * I’m working on a project and I need to create some condition after some rows 
   and I have no idea how to use callback function for that purpose. as you explain
   in the wiki:
    “before, after, before_row, after_row, before_field, after_field:
   These allow you to add arbitrary text/markup at different points in the field
   markup. **These also accept a callback. The callback will receive $field_args
   as the first argument, and the CMB2_Field $field object as the second argument.**“
 * How can I use these callback functions? I mean what are the arguments? Without
   passing any arguments I can achieve what I want. here is an example:
 *     ```
       $cmb->add_field( array(
       		'name' => __( 'test', 'testdomain' ),
       		'id' => $prefix . 'test',
       		'type' => 'text_medium',
       		'on_front' => true,
                       'after_row' => test_callback_function(125),
       	) );
       ```
   
 * and here is my callback function:
 *     ```
       function test_callback_function($another_test_var) {
           $test_var = 123;
           if($another_test_var > $test_var) {
               echo "Great!";
           }
       }
       ```
   
 * problem with this code is that the text “Great!” is shown on the top of the page
   and not after the current row!
 * [https://wordpress.org/plugins/cmb2/](https://wordpress.org/plugins/cmb2/)

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

 *  Plugin Author [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * (@jtsternberg)
 * [10 years ago](https://wordpress.org/support/topic/using-after_row-callback-function/#post-7329113)
 * Change `'after_row' => test_callback_function(),` to `'after_row' => 'test_callback_function',`.
   Callbacks should be registered like you do with add_action or add_filter.
 * As for what arguments are passed in, I’ve updated the wiki to demonstrate a bit
   more: [https://github.com/WebDevStudios/CMB2/wiki/Field-Types#before-after-callbacks](https://github.com/WebDevStudios/CMB2/wiki/Field-Types#before-after-callbacks)
 *  Thread Starter [Arash65](https://wordpress.org/support/users/pershianix/)
 * (@pershianix)
 * [10 years ago](https://wordpress.org/support/topic/using-after_row-callback-function/#post-7329145)
 * Thank you so much! cmb2is awesome!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years ago](https://wordpress.org/support/topic/using-after_row-callback-function/#post-7329185)
 * Thanks pershianix and Justin.

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

The topic ‘using after_row callback function’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

## Tags

 * [callback](https://wordpress.org/support/topic-tag/callback/)

 * 3 replies
 * 3 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/using-after_row-callback-function/#post-7329185)
 * Status: resolved