Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I managed to create new custom fields in the profile page. However, the new fields are located below the Password section. My new fields is more about the user personal details, which should located below/above Biographical Info section. But this new field always display below to the password section, this will be very odd for users to read.

I found a post talking manipulating the DOM by javascript here. But the codes somehow didn't work for me, I don't know why.

So, I would like to find an alternative way. Please advise. Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

let's continue the saga then :)

Yesterday I released a new version of my plugin that deals with customizing the Profile page, among other things. So the subject interests me quite a bit.

I managed to move the whole block of custom usermeta using this answer, but haven't found much room for maneuvering.. Meaning: the usermeta goes in the beginning instead of the end.

Problem is that the profile page doesn't have blocks of html with an assigned ID that would help positioning where we want. I tried to play with jQuery("#your-profile table:nth-child(2)") to no avail...

Anyway, this is the code:

<?php
/*
 #your-profile -> form that holds all profile options (WP default)
 #my-custom-profile -> div wrapping all you custom usermeta html block
*/
function se49859_script_enqueuer(){
    global $current_screen;
    if ($current_screen->id == 'profile') {
        echo '<script type="text/javascript">
        jQuery(document).ready( function($) {
            $("#your-profile").before($("#my-custom-profile"));
        });
        </script>';
    }
}
add_action('admin_head', 'se49859_script_enqueuer');
share|improve this answer
    
I don't know why, the code fails in my test. My custom profile is a table which contain input fields in <tr> so I wrapped the table in a div like this: <div id="mycustomtable"><table><tr><th>field 1</th><td>custom field hre</td></tr><tr><th>field 2</th><td>custom field hre</td></tr>... </table></div>, so I use $("#your-profile").before($("#mycustomtable"));. am I done something wrong? –  dev-jim Apr 22 '12 at 18:01
    
should be all right... does the Firebug/Chrome Inspector throws any error in the console? –  brasofilo Apr 22 '12 at 18:05
    
No luck. I wondering if I using ob_start will affect the result, because I am using it to remove the biography info section function remove_plain_bio($buffer) { $titles = array('#<h3>About Yourself</h3>#','#<h3>About the user</h3>#'); $buffer=preg_replace($titles,'<h3>Password</h3>',$buffer,1); $biotable='#<h3>Password</h3>.+?<table.+?/tr>#s'; $buffer=preg_replace($biotable,'<h3>Password</h3> <table class="form-table">',$buffer,1); return $buffer; } function profile_admin_buffer_start() { ob_start("remove_plain_bio"); } function profile_admin_buffer_end() { ob_end_flush(); } –  dev-jim Apr 22 '12 at 18:10
    
wow, that's a tricky code... never seen it before.. my plugin only uses css and jquery to hide the stuff in the Profile, and the swap function working ok for me –  brasofilo Apr 22 '12 at 18:19
1  
Finally I make it right, turn out there is a conflict in my <div>. Anyway thanks a lot. –  dev-jim Apr 23 '12 at 15:17
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.