WordPress.org

Ready to get started?Download WordPress

Forums

Customize User Profile (2 posts)

  1. Zam
    Member
    Posted 1 year ago #

    Hello Guys...
    First of all, great effort by creating such a page. Appreciated.

    I am here for little help. Here is what i wanna achieve:

    1. I want to add 20 extra fields to User Profile
    2. Profile should be managed from front end
    3. Profile Web Form should be divided into 4 steps containing 5 fields each.

    Any help will be highly appreciated.

  2. curlybracket
    Member
    Posted 1 year ago #

    Try the Cimy User Extra Fields Plugin. Point 1 and 3 managed.

    Point 2. There will be some work to do. I suggest you copy hte HTML code of a user page, as generated by Cimy User Extra Fields to a page template. In the form you will need to ass the correct action URL and you should be set.

    Obviously you could also code all this yourself.

    In functions.php or your plugin try :

    // Twitter, Facebook user extra
    add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
    add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
    
    function my_show_extra_profile_fields( $user ) { ?>
        <h3>Extra profile information</h3>
        <table class="form-table">
            <tr>
                <th><label for="facebook">Facebook</label></th>
                <td>
                    <input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description">Entrez votre URL Facebook (commencer par http://...)</span>
                </td>
            </tr>
            <tr>
                <th><label for="twitter">Twitter</label></th>
                <td>
                    <input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description">Entrez votre username Twitter SANS @.</span>
                </td>
            </tr>
            <tr>
                <th><label for="linkedin">LinkedIn</label></th>
                <td>
                    <input type="text" name="linkedin" id="linkedin" value="<?php echo esc_attr( get_the_author_meta( 'linkedin', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description">Entrez votre URL LinkedIn (commencer par http://...)</span>
                </td>
            </tr>
        </table>
    <?php }
    //SAVING AUTHOR META
    add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
    function my_save_extra_profile_fields( $user_id ) {
        if ( !current_user_can( 'edit_user', $user_id ) )
            return false;
        /* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
        update_usermeta( $user_id, 'twitter', $_POST['twitter'] );
        update_usermeta( $user_id, 'facebook', $_POST['facebook'] );
        update_usermeta( $user_id, 'linkedin', $_POST['linkedin'] );
    }
    ?>

    As you can see, you can use the markup you want and divide the form into 4 or 5 sections.

    As for editing via the frontend, try my previous suggestion.

Topic Closed

This topic has been closed to new replies.

About this Topic