Add description field from buddypress

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Add description field from buddypress

This topic contains 2 replies, has 2 voices, and was last updated by Kahndryl35 Kahndryl35 4 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #27315


    The website is not already online.

    I’m creating a community website for an enterprise using BuddyPress.

    They want list all the skills of their team and the fields must be associated with tags.
    Per example if a member choose “referencing” on the checkbox list they member must be find with the tag “SEO”. For that I created a module to add an input text “tags” of each checkox. And this one is record in the “description” field of the wp_bp_xprofile_fields so it’s not a new column in the database. I’m using a column who already exists. And each tags must be separate with “;”.

    Here is a capture of the table in database :

    In this capture, I would like all members who check the “Assurance” box to appear in the results when we search for “asurance” (only one “s”).

    My question is if it is possible to add the description column from wp_bp_xprofiles_fields in Ajax Search Pro ? And if yes, how ?

    Here is a capture from the dashboard with the new field who uses “description” :
    Thank you in advance.

    Have a good day.


    Steve T.

    Ernest Marcinko
    Ernest Marcinko

    Hi Steve,

    It could be possible, but only programatically. I found a code that I suggested about two years ago about a similar query, that might be useful in your case as well.

    You can enter the profile field names to the $fields variable (line 3), comma separated, and then I believe the code will print them line by line with their labels. I don’t know if this works anymore, buddypress xprofile fields may have changed their API since then.

    Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter('asp_results', 'asp_display_all_fields_user_res', 10, 4);
    function asp_display_all_fields_user_res($results, $sid, $is_ajax, $args) {
      $fields = 'Name,Phone,Test field';  // Enter the fields here, separated by comma
      foreach ($results as $k=>&$r) {
        if ( $r->content_type == 'user' ) {
          $f = array();
          $_fields = asp_get_extended_fields($r->id, $fields);
          foreach ($_fields as $kk => $vv) {
            $f[] = '<strong>' . $vv['name'] . '</strong>: '. $vv['value'];
          if ( count($f) > 0 )
            $r->content = implode('<br>', $f);
      return $results;
    function asp_get_extended_fields( $user_id, $allowed_fields ) {
    	$allowed_fields = str_replace('  ', ' ', $allowed_fields);
      $allowed_fields = str_replace(array(', ', ' ,', ' , '), ',', $allowed_fields);
      $allowed_fields = explode(',', $allowed_fields);
    	$fields = array();
    	/* Get User Extended Data */
    	$r = bp_parse_args( $args['args'], array(
    		'profile_group_id' => 0,
    		'user_id'          =>  $user_id
    	), 'bp_xprofile_user_admin_profile_loop_args' );
    	$i = 0;
    	if ( bp_has_profile( $r ) ) {
    		while ( bp_profile_groups() ) {
    			while ( bp_profile_fields() ) {
    				$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
            $f_name = bp_get_the_profile_field_name();
            if ( !in_array($f_name, $allowed_fields) )
    				$fields[$i]['name'] = $f_name;
    				$fields[$i]['id'] = bp_get_the_profile_field_input_name();
    				$fields[$i]['value'] = bp_get_the_profile_field_edit_value();
    	return $fields;
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    Hi Ernest,

    Thank you for your time.

    I did the job with an other solution.

    I would like to user Custom Fields, but they are only usable on usermeta or postmeta.,Then, after submit a register form, I record all datas to a new usermeta “xprofile_fields”.

    And now I can the filter on it. Here is my code :

    function xprofile_data_after_save_to_usermeta_for_search( $obj ) {
    	update_user_meta( $obj->user_id, 'xprofile_fields_' . $obj->field_id, $obj->value );
    add_action( 'xprofile_data_after_save', 'xprofile_data_after_save_to_usermeta_for_search' );

    Thank you for your time !


    Steve T.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.