Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
functions to show the field data or ask to fill it
//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
You can’t perform that action at this time.