Skip to content

Instantly share code, notes, and snippets.

View ymsstudios's full-sized avatar

Martin Schwartz ymsstudios

View GitHub Profile
@emoop
emoop / custom field filter
Created February 17, 2014 21:07
Get product custom field when get product in Woocmmerce REST API
<?php
/* if you have get a custom field use this filter*/
add_filter('woocommerce_api_product_response','get_custom_field');
// '_brand' is my custom field
function get_custom_field($product){
$product['brand']=get_post_meta($product['id'],'_brand',true);
return $product;
}
@magnific0
magnific0 / wp_usermeta.md
Last active October 9, 2024 00:35
Show and Edit User Meta in Wordpress

Show and Edit User Meta in Wordpress

Description

This simple procedure will allow you to:

  1. Display user meta fields under in the user list as additional columns (Users > All Users).
  2. Display these fields on user profiles.
  3. Edit these fields under user edit.

This method works completely without plugins and involves just some functions and hooks in functions.php. Plugins like "User Meta Display" achieve this to some level, but treat custom meta fields completely different from the regular fields. They are shown and edited in seperate environment and fail to show the meta data is a table list. This method integrates custom user meta along with regular user (meta).