I tried to use the user_meta_form_display hook and a str_replace to wrap a bunch of fields in a div. I used an approach similar to the one I used to add the novalidate attribute to the <form> tag … like this:
I want to wrap field groups in their own divs so I can use css to have two+ column forms. I tried the section heading fields and html fields provided in User-Meta pro with no luck.
I could do a string replace and add an opening and closing div where I wanted them. But a mysterious force keeps closing my opening div in the same line and tossing out my closing div.
I could actually get one div wrapped around a bunch of fields using a section heading field as the opening div and an html field as the closing div. But User-Meta would only do that once per form. Not much use.
With JQuery wrapAll it’s no problem. But is there a way to do it with php?
I fooled with this for awhile but finally got it to work with a string replace.
It would probably be better done using php domhtml but I had trouble using the user_meta_form_display hook with it because the load($html) just returned the form and not the other content on the page, But without the user_meta_form_display hook I couldn’t even access the form $html. Neither could I see the form $html using the_content (wp codex) with or without do_shortcode. Good thing User-Meta has these hooks … thanks.
The problem with the string replace is that spacing inconsistencies in the html mess it up. That is why my initial attempts failed. But if you keep your string replacements small it can work once you figure out the spacing patterns. Regex was not necessary.
I used User-Meta to add simple html fields where I wanted my column divs to be. I show the string replace here in two steps. First step was to get ride of the spaces and consolidate the simple html divs. Second step replaced the simple divs with more complex divs having id’s and such for styling colums.
This reply was modified 9 years, 9 months ago by gvh.
Author
Posts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptRead More
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.