1

I am running a website that has users input phone number and carrier when they register. Using the Phone module to collect the phone number and a select list field to collect the carrier. How can I retrieve these variables so that I can combine them to make a phone email address (eg. 123456789@vzwtxt.com)

I have a plan for combining them I just need to know how to get the phone number out of the array based on the uid so that I can combine it with the carrier.

Thank you!

6
  • Welcome to Drupal Answers. This question seems to be lacking some basic information to help us, help you. Where are you trying to access the information? what are the field names? are you looking for code, or UI based? are you looking to implement this in a module (like views)? what have you tried so far? – Geoff Jul 15 '14 at 19:23
  • @Geoff My apologies. I am looking for a code solution. I am currently trying to access the information from inside the user_profile.page.tpl and i have tried using $account field_phone_number and $user. The first gets me an array output because i do not know how to get the information based on uid. – JDSlimz Jul 15 '14 at 20:57
  • if don't already have it, get DEVEL module (drupal.org/project/devel). In your tpl file, use dpm($account); this will output the array. From there you can determine the proper element names – Geoff Jul 15 '14 at 21:04
  • Ok, so i put in the line you provided and narrowed it down to the field I was looking for dpm($field_phone_number); Its Output ... (Array, 1 element) 0 (Array, 1 element) value (String, 14 characters ) (123) 456-7890 How do I get it do display the string and not just "Array" when I print it? – JDSlimz Jul 15 '14 at 22:13
  • if I interpret what you wrote correctly, it would be $field_phone_number[0]['value']; a trick to figuring out the exactly lineage is to progressively use dpm, ie: dpm($account), dpm($field_phone_number), dpm($field_phone_number[0]), etc. this is an easy one, but arrays can get in depth and complicated within Drupal – Geoff Jul 15 '14 at 22:37
0

if you don't already have it, get DEVEL module. In your tpl file, use dpm($account); this will output the array. From there you can determine the proper element names.

it would be $field_phone_number[0]['value']; a trick to figuring out the exactly lineage is to progressively use dpm, ie: dpm($account), dpm($field_phone_number), dpm($field_phone_number[0]), etc. this is an easy one, but arrays can get in depth and complicated within Drupal

Devel:

Helper functions for Drupal developers and inquisitive admins. This module can print a summary of all database queries for each page request at the bottom of each page. The summary includes how many times each query was executed on a page (shouldn't run same query multiple times), and how long each query took (short is good - use cache for complex queries). Also a dprint_r($array) function is provided, which pretty prints arrays. Useful during development. Similarly, a ddebug_backtrace() is offerred.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.