1. Home
  2. Docs
  3. WP User Frontend Pro
  4. Tutorials
  5. Adding columns to dashboard table

Adding columns to dashboard table

You can add your own dashboard columns to the WP User Frontends dashboard table.

Adding Column Header

It provides a action hook wpuf_dashboard_head_col, using this you can add a column:

/**
 * Add a new column header in dashboard table
 *
 * @param array $args dashboard query arguments
 * @return void
 */
function wpufe_dashboard_change_head( $args ) {
    printf( '<th>%s</th>', __( 'Sub Title', 'wpuf' ) );
}

add_action( 'wpuf_dashboard_head_col', 'wpufe_dashboard_change_head', 10, 2 );

Adding table rows

Now, you add your row via wpuf_dashboard_row_col, which provides two parameters: $args and $post.

/**
 * Add a new table cell to the dashboard table rows.
 * It adds a form for changing the post status of each posts via ajax call.
 *
 * @param array $args dashboard query arguments
 * @param object $post current rows post object
 * @return void
 */
function wpufe_dashboard_row_col( $args, $post ) {
    ?>
    <td>
        <?php
        if ( $sub = get_post_meta( $post->ID, 'subhead', true ) ) {
            echo $sub;
        } else {
            echo '---';
        }
        ?>
    </td>
    <?php
}

add_action( 'wpuf_dashboard_row_col', 'wpufe_dashboard_row_col', 10, 2 );

WP User Frontend - Dashboard Columns

Was this article helpful to you?

How can we help?