WordPress: Add an extra column in the All Users admin page

WordPress development involves extending information were possible to suite business needs. For those that need to add an extra column in the Users table, heres how to do it in your plugin or functions.php file.

function all_columns( $columns ){
   $columns['cool_column'] = 'Column Header';
   return $columns;
}

function custom_column_content( $content, $column, $user_id ){
   if ( $column === 'cool_column' ) {
      $content = "custom data";
      return $content;
   }
}

add_filter( 'manage_users_columns', 'all_columns' );
add_filter( 'manage_users_custom_column', 'custom_column_content', 10, 3 );

WooCommerce: How to Bulk Edit Primary Category (Yoast Plugin Feature) using Pimwick’s PW Bulk Edit

Hi Guys,

This is how you bulk edit. Change the view to ‘Primary Categories’ as below. This will get rid of all the other columns we don’t need whilst bulk editing the primary category.

To apply a bulk edit to all your search results, clicked on the ‘Primary Category’ column heading and click ‘Edit All Checked Products’.

Then select what primary category you want to apply to all of them within the next window. Then click apply. Then click ‘save changes’

WooCommerce: Get children of a grouped product

Here is a simple example.

/**
 * Test creating a new grouped product.
 *
 * @since 2.7.0
 */
function test_grouped_product_create()
{
    $simple_product = WC_Helper_Product::create_simple_product();
    $product = new WC_Product_Grouped();
    $product->set_children(array($simple_product->get_id()));
    $product->set_name('My Grouped Product');
    $product->save();
    $read_product = new WC_Product_Grouped($product->get_id());
    $this->assertEquals('My Grouped Product', $read_product->get_name());
    $this->assertEquals(array($simple_product->get_id()), $read_product->get_children());
}