Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display first 2-3 lines of 'About Me' xprofile field in Member's Directory

  • Avatar of dta_madrid
    dta_madrid
    Participant

    @dta_madrid

    Could anyone help me with a bit of php for the member’s loop. I would like to show the first few lines of what a user has written in their ‘About Me’ xprofile field in the Member’s Directory along with ‘…’ to show there is more to read.

    I know how to display xprofile field info in the Directory listing but not how to display just a little part of it.

    Thanks a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of Henry
    Henry
    Participant

    @henrywright-1

    The best approach would be to filter the data before you display it to screen. The general idea would be something like this

    
    function filter_about_me_info( $value, $field_id, $user_id ) {
        if (  bp_is_directory() ) {
            $value = wordwrap( $value, 16 );
            $value = explode( "\n", $value );
            $value = $value[0] . '...';
        }
        $return $value;
    }
    add_filter( 'xprofile_get_field_data', 'filter_about_me_info', 10, 3 );
    

    Note: I haven’t tested it.

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    Actually apologies – not convinced this will achieve what you want it to

    $value = wordwrap( $value, 16 );
     $value = explode( "\n", $value );
     $value = $value[0] . '...';
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.