How do I parse the value of a checkbox xProfile field
-
I have an xProfile field named Specialty and defined as type=checkbox with 4 options: Area1, Area2, Area3 and Area4.
I can retrieve a specific members settings for this field via the following two lines of PHP:
get_var(“SELECT `value` FROM wp_bp_xprofile_data WHERE `user_id` = $id AND `field_id`= $fieldID”); ?>
For example, the output for someone with Area1, Area2 & Area4 checkmarked is a:3:{i:0;s:5:”Area1″;i:1;s:5:”Area2″;i:2;s:5:”Area4″;}
This appears to be some type of encoded array but I can’t find anything that explains the format.
I think I’ve figured out that (a:3) above means an Array of 3 elements and the first element (i:0;s:5:”Area1″) means the key is an integer of value 0 pointing to a string of 5 characters who value is Area1
MY QUESTIONS:
1) is this format documented anywhere?
2) are there bp_* functions already defined that will properly parse this information?
- The topic ‘How do I parse the value of a checkbox xProfile field’ is closed to new replies.