I'm able to get this working in a shortcode. However, I need to know how to output the auto-generated meta values (it's an auto-generated token) which is


This is the array from the current logged-in user's meta (have changed some values for security reason) :

array(1) {
array(1) {
array(7) {
  string(11) "credit_card"
  string(4) "2129"
  string(10) "mastercard"
  string(2) "10"
  string(4) "2022"
  string(2) "sz"}

This is the code I'm able to get it working:

    function user_cc_info_shortcode() {

if(is_user_logged_in()) {

    $user_id = get_current_user_id();
    $cc_meta = get_user_meta($user_id, '_wc_braintree_credit_card_payment_tokens', false);
    $last_four = $cc_meta[0]["bepdf6q"]["last_four"];



    $out = ob_get_clean();
    echo $out;
add_shortcode('currentuser_show_cc_info', 'user_cc_info_shortcode');

which output ["last_four"] as 2129.

But ["bepdf6q"] is an auto-generated value, so I can't include it in :

$last_four = $cc_meta[0]["bepdf6q"]["last_four"];

So, is there any other way so that I can output the ["last_four"] value?

I use this plugin for the payment method: https://wordpress.org/plugins/woocommerce-gateway-paypal-powered-by-braintree/

Thank you.

  • I guess you could try looping over the array if you don't know the array keys beforehand. – birgire Aug 23 '18 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.