Created
September 4, 2011 20:55
-
-
Save sbrajesh/1193494 to your computer and use it in GitHub Desktop.
functions to show the field data or ask to fill it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//pass the field name as string | |
function show_or_ask_to_fill($field_name){ | |
$data= xprofile_get_field_data($field_name, bp_loggedin_user_id()); | |
if(empty($data)){ | |
$field_id=xprofile_get_field_id_from_name($field_name); | |
$group_id=custom_get_group_from_field($field_id); | |
echo sprintf("Please click <a href='%s'>%s</a> to fill the data", bp_get_loggedin_user_link()."profile/edit/group/".$group_id."/#field_".$field_id,$field_name); | |
} | |
else | |
echo "{$field_name}:{$data}"; | |
} | |
//get field group id from field name | |
function custom_get_group_from_field($id){ | |
if(empty($id)) | |
return false; | |
global $bp,$wpdb; | |
$group_id=$wpdb->get_var($wpdb->prepare("SELECT group_id FROM {$bp->profile->table_name_fields} WHERE id=%d",$id)); | |
return $group_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment