How To Get Plaintext Multiline Field?
-
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!
-
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?
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!
One way to do it is to hide it using custom css in your child theme/theme stylesheet.
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.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-
and also searching the buddypress install for ‘multiselectbox’– just to see how that one gets handled π
thx!
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.phpi welcome any suggestions on which of these i actually need to edit, at minimum, to create a new field-type.
thx!
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>
….
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=0i 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
}’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; }
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-8009134thx!
Correct. My answer only disables rich text for specific fields; the other answer disables rich text for all fields. Pick your poison. π
donmik has developed a new plugin, providing a checkbox on the field editor to disable rich-text.
https://github.com/donmik/bp-xprofile-custom-textarea/releases/tag/0.1.1
http://donmik.com/en/how-to-disable-richtext-editor-for-textarea-buddypress-field-type/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
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.1I only want plain text for buddypress user profiles.
Best regards
Margarita
I am using the plugin “TinyMCE Advanced” for wordpress pots, maybe it makes the error, but I need it for wordpress posts.
- You must be logged in to reply to this topic.