Skip to:
Content
Pages
Categories
Search
Top
Bottom

How To Get Plaintext Multiline Field?


  • johnywhy
    Participant

    @johnywhy

    hi!

    We need a plain text multiline field (without formatting toolbar). Like HTML “textarea” element.

    Is there a way to hide the formatting toolbar in the built-in multiline textbox? What kind of textbox is that TinyMCE?

    Or, can we add a new fieldtype? i could not find instructions for this– if possible, plz link me to instructions.

    thx for all help!

Viewing 16 replies - 1 through 16 (of 16 total)

  • calvin
    Participant

    @calvinorenda

    could not understand your question. where exactly do you plan to put this textarea in buddypress? in profile field, regi form, in a member page or where?


    johnywhy
    Participant

    @johnywhy

    hi, thx for reply.

    enter in user registration form, and display in user front-end profile.

    want to be able to use it like any other field in “user fields” editor.

    thx!


    calvin
    Participant

    @calvinorenda

    One way to do it is to hide it using custom css in your child theme/theme stylesheet.


    calvin
    Participant

    @calvinorenda

    After adding the fields you want using xprofile, go to your regi page. If you are using google chrome, right click on the multiline box and inspect

    you should find out the the id of the visual/text box something similar this ‘wp-field_664-editor-tools’ (yours should be a bit different cos field number is different)

    you should also find out the id of the mce panel using the same method

    After that you should be able to add the custom css to your theme stylesheet.
    Example (hiding the item using css):
    #wp-field_664-editor-tools {display:none;}

    You may need to double check on the edit profile page. if it still appears there, you can use the same method to hide it.
    Hope this helps.


    johnywhy
    Participant

    @johnywhy

    thx for that! css will be our quick-and-dirty fallback. But not a long-term solution.

    it would be cool to develop a proper control. i’m guessing this is part of the recipe for displaying on the user-profile page:

    bp_profile_field_data()

    but would be awesome if someone can share the full recipe to develop a custom field.

    i’m looking here for clues-

    Profile Fields Loop

    and also searching the buddypress install for ‘multiselectbox’– just to see how that one gets handled πŸ™‚

    thx!


    johnywhy
    Participant

    @johnywhy

    i found ‘multiselectbox’ in the following files:

    buddypress.pot
    buddypress.pot
    buddypress.pot
    buddypress.pot
    bp-members\admin\css\admin-rtl.css
    bp-members\admin\css\admin-rtl.min.css
    bp-members\admin\css\admin.css
    bp-members\admin\css\admin.min.css
    bp-themes\bp-default\functions.php
    bp-themes\bp-default\functions.php
    bp-themes\bp-default\functions.php
    bp-themes\bp-default\functions.php
    bp-themes\bp-default\members\single\profile\edit.php
    bp-themes\bp-default\registration\register.php
    bp-xprofile\bp-xprofile-classes.php
    bp-xprofile\bp-xprofile-functions.php
    bp-xprofile\bp-xprofile-template.php
    bp-xprofile\bp-xprofile-template.php
    bp-xprofile\admin\js\admin.js
    bp-xprofile\admin\js\admin.min.js
    bp-xprofile\classes\class-bp-xprofile-field-type-multiselectbox.php
    bp-xprofile\classes\class-bp-xprofile-field-type-multiselectbox.php
    bp-xprofile\classes\class-bp-xprofile-field-type-multiselectbox.php
    bp-xprofile\classes\class-bp-xprofile-field-type-multiselectbox.php
    bp-xprofile\classes\class-bp-xprofile-field-type.php
    bp-xprofile\classes\class-bp-xprofile-field-type.php
    bp-xprofile\classes\class-bp-xprofile-field-type.php

    i welcome any suggestions on which of these i actually need to edit, at minimum, to create a new field-type.

    thx!


    johnywhy
    Participant

    @johnywhy

    hmm, ok, taking a different approach. i’m inspecting donmik’s files in ‘buddypress-xprofile-custom-fields-type’. Hope that’s ok, donmik!

    i found ‘datepicker’ in:

    bp-xprofile-custom-fields-type.php
    classes\Bxcft_Field_Type_Datepicker.php
    lang\buddypress-xprofile-custom-fields-type.pot
    lang\en_US.mo
    lang\en_US.po

    (ignoring the non-english files for the moment).

    i simply duplicated all the ‘datepicker’ code-chunks in these files, and replaced ‘datepicker’ with ‘textarea’.

    also duplicated the file ‘classes\Bxcft_Field_Type_Datepicker.php’, renamed it ‘Bxcft_Field_Type_Textarea.php’, and removed any date-specific code i found there.

    and so on and so forth.

    then i zipped it, uploaded to wordpress, activate, and added my new Textarea field to a form.

    i actually got no errors, and actually got a text field on my registration form!

    unfortunately, it’s only a one-line textbox, not a multiline textarea.

    hrm. In inspector, the displayed field is:

    <input type="string">

    so something in donmik’s code, or BP, or WP, is causing this to render as an <input> rather than <textarea>

    ….


    johnywhy
    Participant

    @johnywhy

    note, i also edited the .po file, and generated a new .mo from that

    you can download my zip here:
    https://www.dropbox.com/s/nx0ox3weg5khlpi/buddypress-xprofile-custom-fields-type-JW-TEXTAREA.zip?dl=0

    i noticed modernizr.js mentions ‘textarea’. Not sure what it’s doing, but i don’t think this is the cause:
    ‘ var c = a.html5 || {},
    d = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,
    e = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,
    f, g = “_html5shiv”,
    h = 0,
    i = {},
    j;
    (function() {
    try {
    var a = b.createElement(“a”);
    a.innerHTML = “<xyz></xyz>”, f = “hidden” in a, j = a.childNodes.length == 1 || function() {
    b.createElement(“a”);
    var a = b.createDocumentFragment();
    return typeof a.cloneNode == “undefined” || typeof a.createDocumentFragment == “undefined” || typeof a.createElement == “undefined”
    }()
    } catch (c) {
    f = !0, j = !0
    }’


    johnywhy
    Participant

    @johnywhy

    In case anyone is wondering why we would want a plaintext field:

    We don’t want our members formatting their bios with bold text, big fonts, colors, etc etc. We want our CSS to control presentation.

    Hi Johnywhy-

    You can disable the rich text editor on a per-field basis using the filter bp_xprofile_is_richtext_enabled_for_field which was added when the wp_editor was added.

    You might do

    
    add_filter( 'bp_xprofile_is_richtext_enabled_for_field', 'my_disable_rt_function', 10, 2 );
    function my_disable_rt_function( $enabled, $field_id ) {
      // 14 is the id of the field I want to be plain text.
      if ( 14 == $field_id ) {
        $enabled = false;
      }
      return $enabled;
    }
    

    johnywhy
    Participant

    @johnywhy

    thank you very much!

    your solution is slightly different from this other one, which helps me learn.
    https://wordpress.org/support/topic/how-to-add-textarea-field-to-buddypress-xprofile-custom-fields-type?replies=5#post-8009134

    thx!

    Correct. My answer only disables rich text for specific fields; the other answer disables rich text for all fields. Pick your poison. πŸ™‚


    johnywhy
    Participant

    @johnywhy


    reivilob
    Participant

    @reivilob

    donmik, johnywhy

    You are kings !
    I looked a solution for a long time, i install your plugin, works fine and you save me probably a lot of hours …

    Olivier


    margarit0
    Participant

    @margarit0

    Thank you very much.

    I have installed the plugin from this link:
    http://donmik.com/en/how-to-disable-richtext-editor-for-textarea-buddypress-field-type/

    then I can disabled the rich-text from the backend, but if I am conected like a user I can not see the change I am seeing a rich-text not a plain-text like when I am log in as the admin.

    I have remove the cookies, but the problem persists.

    I need to install also the plugin of this othe rlink?:
    https://github.com/donmik/bp-xprofile-custom-textarea/releases/tag/0.1.1

    I only want plain text for buddypress user profiles.

    Best regards

    Margarita


    margarit0
    Participant

    @margarit0

    I am using the plugin “TinyMCE Advanced” for wordpress pots, maybe it makes the error, but I need it for wordpress posts.

Viewing 16 replies - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.
Skip to toolbar