How to get current user’s phone number

I’m trying that :

<?php $phone = get_user_meta($current_user->ID,'phone_number',true); echo $phone; ?>

But it’s not working

5 Answers
5

<?php
  // number 9 will be user ID
  $all_meta_for_user = get_user_meta( 9 );
  print_r( $all_meta_for_user );

// find the key that you want
Array ( 
    [first_name] => Array ( [0] => Tom ) 
    [last_name] => Array ( [0] => Auger) 
    [nickname] => Array ( [0] => tomauger ) 
    How to get current user's phone number => etc.... 
)

// store it in a variable 
$last_name = $all_meta_for_user['last_name'][0];

// display it 
echo $last_name;

Leave a Comment