Adding BP group name or ID to woocommerce orders list page in admin
-
Hello everyone,
I am trying to add a “group/s name” or “group/s ID” column to the Woocommerce orders list page in Admin panel.
It should show for each order line in the list the bp group that the user is registered to.
On this website except for admins, all the members are each registered to one bp group only.Using the following code I can add a sortable column but I a breaking my fingers trying to get the BP group ID or name to show as the values.
add_filter( 'manage_edit-shop_order_columns', 'MY_COLUMNS_FUNCTION' ); function MY_COLUMNS_FUNCTION($columns){ $new_columns = (is_array($columns)) ? $columns : array(); unset( $new_columns['order_actions'] ); //edit this for you column(s) //all of your columns will be added before the actions column $new_columns['MY_COLUMN_ID_1'] = '????'; //stop editing $new_columns['order_actions'] = $columns['order_actions']; return $new_columns; } add_action( 'manage_shop_order_posts_custom_column', 'MY_COLUMNS_VALUES_FUNCTION', 2 ); function MY_COLUMNS_VALUES_FUNCTION($column){ global $post; $data = get_post_meta( $post->ID ); //start editing, I was saving my fields for the orders as custom post meta //if you did the same, follow this code if ( $column == 'MY_COLUMN_ID_1' ) { echo (isset($data['MY_COLUMN_1_POST_META_ID']) ? $data['MY_COLUMN_1_POST_META_ID'] : ''); } //stop editing } add_filter( "manage_edit-shop_order_sortable_columns", 'MY_COLUMNS_SORT_FUNCTION' ); function MY_COLUMNS_SORT_FUNCTION( $columns ) { $custom = array( //start editing 'MY_COLUMN_ID_1' => 'MY_COLUMN_1_POST_META_ID' //stop editing ); return wp_parse_args( $custom, $columns ); }
Any idea on what I should add to the functions so that the new custom column will be for Group ID or Group Name?
- The topic ‘Adding BP group name or ID to woocommerce orders list page in admin’ is closed to new replies.