Hello @foots,
Please have a look at the following documentation to customize user dashboard. You don’t need to edit the plugin core files directly as you lose the changes after updating the plugin. Just include custom functions toward the end of your functions.php, which is located in your theme folder.
https://wedevs.com/docs/wp-user-frontend-pro/tutorials/adding-columns-to-dashboard-table/
Thank you
Thread Starter
foots
(@foots)
Hi Mahbubur,
Thank you for your reply, apologies it has taken me some time to reply.
I followed the guide and I’ve added a column to the dashboard, how can I show the post id in that column?
Many thanks
Thread Starter
foots
(@foots)
Hello Mahbubur,
I’ve tried the following code to show the post ID in the dashboard, but all I get is —
Do you have any advice on where I’m going wrong?
Many thanks.
/* ADD ABSTRACT ID TO DASHBOARD */
/**
* 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>’, __( ‘Abstract ID’, ‘wpuf’ ) );
}
add_action( ‘wpuf_dashboard_head_col’, ‘wpufe_dashboard_change_head’, 10, 2 );
/**
* 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 );
-
This reply was modified 7 years ago by foots.
Hello @foots,
Thanks for your try, but there was a simple mistake. However, you can use the following code to show post ID in a separate column on the frontend dashboard. Add the following code inside the theme’s functions.php file. It should work.
/**
* 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>', __( 'ID', 'wpuf' ) );
}
add_action( 'wpuf_dashboard_head_col', 'wpufe_dashboard_change_head', 10, 2 );
/**
* 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_id( $args, $post ) {
?>
<td>
<?php
if ( $post ) {
echo $post->ID;
}
?>
</td>
<?php
}
add_action( 'wpuf_dashboard_row_col', 'wpufe_dashboard_row_col_id', 10, 2 );
Thank you
Thread Starter
foots
(@foots)
Hello Mahbubur,
That worked perfectly! Thank you kindly for your help.
All the best!
Hello @foots,
Thanks for the updates. Nice to hear that you are able to see the post id on the frontend dashboard. Let me know if there is any other issue. I will be happy to help you.