Skip to:
Content
Pages
Categories
Search
Top
Bottom

Line breaks in profile fields descriptions not showing

  • @applegateian

    Participant

    Hi guys

    I’ve seen this topic before, but in quite an old thread.

    I have created some multi-line text boxes in Profile Fields, but when the user completes a form with line breaks, these are not appearing in the front end.

    When I inspect the HTML, the breaks appear, but they do not show up to the user. Here is how the html looks and how the front end renders:


    I am running BuddyPress 2.0.2 with WordPress 4.0, running Reverie Theme.

    How can I get the line breaks to appear?

    Thanks,

    Ian

Viewing 7 replies - 1 through 7 (of 7 total)
  • @henrywright

    Moderator

    Hi Ian

    wpautop() is a function you could use for this. Check out:
    https://codex.wordpress.org/Function_Reference/wpautop

    @applegateian

    Participant

    Thanks for the pointer @henrywright – I’ve tried a few executions but can’t seem to generate the breaks/p tags that are needed.

    Here is an example of where I am seeing the problem with profile fields – is there a way within the text that is outputted to enable wpautop? Thanks…

    	<div class="keyPeople">
    		<?php 
    		if (bp_get_profile_field_data('field=Key People') == "") :
    		echo '';
    else:
    // display code
    		$data=bp_get_member_profile_data(array('field'=>'Key People'));
    		echo '<h3>Key People</h3>';
    		echo $data; 
    endif;
    		?>
    	</div>	

    @hnla

    Participant

    In the intervening 10 days what have you actually tried though?

    Stating I’ve tried a few executions isn’t very helpful as it tells us nothing about what exactly you have tried, or shows us code attempts that may have errors. Without knowing what you are trying it’s not possible to give any sort of useful help, as things stand given the code you showed originally and henrywrights response there’s the answer ( wpautop() )and it’s relatively simple to apply.

    Instead of us speculating at what’s wrong and throwing up a multitude of possible code scenarios that might work which is wasteful of time and energy, provide some useful data to work from please, especially if you’re a developer.

    @applegateian

    Participant

    Apologies, I’m not a developer but trying to find a solution that works.

    I tried editing bp-profile-filters.php by adding add_filter( ‘xprofile_get_field_data’,’wpautop’ );

    I also tried upgrading Buddypress Xprofile Custom Fields Type plugin, as it was out of date, but this hasn’t helped.

    From my rudimentary understanding, What I think I need to do is edit echo $data; to somehow include wpautop but I am not finding a way to do that…apologies if it is simple.

    Thanks,

    Ian

    @hnla

    Participant

    🙂 Sounds like you tried to tackle a heap of things far more complex than the actual solution you need!

    > What I think I need to do is edit echo $data; to somehow include wpautop but I am not finding a way to do that…

    er…

    Henrywrights link?

    You did read that page didn’t you? 🙂

    Sorry not being mean 🙂 but your solution is there to be read, if you really don’t get it or for whatever reason once tried it fails to produce results (do, though, ensure data has double line breaks) post back with code tried and we’ll look further.

    @applegateian

    Participant

    Hi @hnla I appreciate the help, and yes I did read it…just not sure I was interpreting it correctly.

    Thanks for the help, I got this working as follows:

    .....// display code
    		$data=bp_get_member_profile_data(array('field'=>'Experience'));
    		echo '<h3>Experience</h3>';		
    		echo wpautop($data);
    endif;	
    		?>

    Ian

    @hnla

    Participant

    not really help but nudges in the right direction 🙂
    wpautop($data) was all you needed.

    However there something niggling away about these bp functions and point at which the xprofile functions gets passed through the WP ‘wpautop’, not sure that the get function shouldn’t be parsing breaks to paragraph tags regardless but hey ho.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Line breaks in profile fields descriptions not showing’ is closed to new replies.
Skip to toolbar