WordPress.org

Ready to get started?Download WordPress

Forums

Custom Edit Profile Page (19 posts)

  1. MeCrob
    Member
    Posted 5 years ago #

    I simply want to make a profile page where registered users can edit/update their information outside of the WP back-end. I want to have a form seamlessly put onto my site. I've gotten as far as creating a profile page with the form that pulls the user data into it. I just can't seem to get it to save when edits are made.

    Has anyone successfully done this type of customization who can provide some tips? I've spent several hours searching around for answers, but I can't seem to find any.

    Any help would be highly appreciated and save whatever hair I have left that hasn't been pulled out!
    - MeCrob

  2. peterberg
    Member
    Posted 5 years ago #

    Hi MeCrob
    looking for same stuff, google didnt help.
    Did you succeed up to now somehow?

    Thanks
    PB

  3. eme_pe
    Member
    Posted 5 years ago #

    Same here. Does anyone know about some wordpress site that has something like that?

  4. Cryo
    Member
    Posted 5 years ago #

    I would like to know this too.

  5. j-c-r-w
    Member
    Posted 5 years ago #

    Hi all.
    This is exactly what I wanted too.
    I just now was searching for an answer when I got it by clicking the wrong button.

    Here it is:
    I installed the WP Plugin "Theme my login"
    http://wordpress.org/extend/plugins/theme-my-login/

    This customizes (you can edit the includes yourself) the login etc. pages for the user.
    If you now login to the page, the forms etc. look a bit different and can all be edited.
    Luckily I realized that if you do log in as an abonnent you will be redirected from the /wp-admin to a normal single page within the frontend that reads out the user data and lets you change them.

    That works for me so far.

    Please let me know about other code or plugins that will be more flexible may be.

    Hope I could help.

  6. Jeff Farthing
    Member
    Posted 5 years ago #

    Actually, the way it now works is by creating a WordPress 'page' for the login and therefore utilizing your theme's 'page.php' template. You could even create a custom template and specify it for the 'Login' page just as you would any other custom page template.

    I made it this way for simplicity, because a lot of people were having a hard time trying to figure out what files to include and what HTML went where according to their theme. The only downside of this method is that any plugin that utilizes a user options page, such as subscribe2, will not be able to access that user page with the themed profile. However, as of version 2.0.6, I have added the option to turn off the profile theming, for those of you who are using any conflicting plugin. Meanwhile, the login, registration and forgot password forms will still be themed.

    http://www.wordpress.org/extend/plugins/theme-my-login

  7. Tony2Nice
    Member
    Posted 4 years ago #

    Dude. You just made my night. That is exactly what I was after, and much more. I'll be sending a few dollars your way as soon as I get paid.

    Thanks so much for the plugin.

  8. jimzqui
    Member
    Posted 4 years ago #

    Hi to all, I was searching help for another topic when I came across this thread.

    To MeCrob and others, reading from your posts, I think I know what exactly you wanted. You can try this steps if you want.

    1.) I suggest you create a page template.
    -------------------------------------------------------------------
    2.) Paste the following PHP code before the get_header() on the topmost of your template. In this example, the template name is 'My Account'.
    <?php
    /*
    Template Name: My Account
    */
    $wpdb->hide_errors(); auth_redirect_login(); nocache_headers();
    global $userdata; get_currentuserinfo(); // grabs the user info and puts into vars
    // check to see if the form has been posted. If so, validate the fields
    if(!empty($_POST['action']))
    {
    require_once(ABSPATH . 'wp-admin/includes/user.php');
    require_once(ABSPATH . WPINC . '/registration.php');
    check_admin_referer('update-profile_' . $user_ID);
    $errors = edit_user($user_ID);
    if ( is_wp_error( $errors ) ) {
    foreach( $errors->get_error_messages() as $message )
    $errmsg = "$message";
    //exit;
    }
    // if there are no errors, then process the ad updates
    if($errmsg == '')
    {
    do_action('personal_options_update');
    $d_url = $_POST['dashboard_url'];
    wp_redirect( get_option("siteurl").'?page_id='.$post->ID.'&updated=true' );
    }
    else {
    $errmsg = '<div class="box-red">** ' . $errmsg . ' **</div>';
    $errcolor = 'style="background-color:#FFEBE8;border:1px solid #CC0000;"';
    }
    }
    ?>
    ------------------------------------------------------------------
    3.) Now for the form, paste the following code anywhere in your body/content area. Im using here tables for the html, but you can customize it depends on your taste.
    <h2 class="h2top"><?php echo $GLOBALS['_LANG']['_accinfo']; ?></h2>

    <?php if ( isset($_GET['updated']) ) {
    $d_url = $_GET['d'];?>
    <p class="message"><?php _e('Your profile has been updated.','cp')?></p>
    <?php } ?>
    <?php echo $errmsg; ?>
    <form name="profile" action="" method="post">
    <?php wp_nonce_field('update-profile_' . $user_ID) ?>
    <input type="hidden" name="from" value="profile" />
    <input type="hidden" name="action" value="update" />
    <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    <input type="hidden" name="dashboard_url" value="<?php echo get_option("dashboard_url"); ?>" />
    <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
    <table class="form-table" style="640px;">
    <tr>
    <th><label for="user_login"><?php _e('Username','cp'); ?></label></th>
    <td><input type="text" name="user_login" class="mid2" id="user_login" value="<?php echo $userdata->user_login; ?>" size="35" maxlength="100" disabled /></td>
    </tr>
    <tr>
    <th><label for="first_name"><?php _e('First Name','cp') ?></label></th>
    <td><input type="text" name="first_name" class="mid2" id="first_name" value="<?php echo $userdata->first_name ?>" size="35" maxlength="100" /></td>
    </tr>
    <tr>
    <th><label for="last_name"><?php _e('Last Name','cp') ?></label></th>
    <td><input type="text" name="last_name" class="mid2" id="last_name" value="<?php echo $userdata->last_name ?>" size="35" maxlength="100" /></td>
    </tr>
    <tr>
    <th><label for="email"><?php _e('Email','cp') ?></label></th>
    <td><input type="text" name="email" class="mid2" id="email" value="<?php echo $userdata->user_email ?>" size="35" maxlength="100" /></td>
    </tr>
    <tr>
    <th><label for="url"> Website URL</label></th>
    <td><input type="text" name="url" class="mid2" id="url" value="<?php echo $userdata->user_url ?>" size="35" maxlength="100" /></td>
    </tr>
    <tr>
    <th><label for="description"><?php echo $GLOBALS['_LANG']['_accme']; ?></label></th>
    <td><textarea name="description" class="mid2" id="description" rows="8" cols="50"><?php echo $userdata->description ?></textarea></td>
    </tr>
    <tr>
    <th><label for="description">Resume</label></th>
    <?php
    $value = get_cimyFieldValue($user_ID, 'RESUME');
    ?>
    <td><textarea name="resume" class="mid2" id="resume" rows="8" cols="50"><?php echo cimy_uef_sanitize_content($value); ?></textarea></td>
    </tr>
    </table>
    <p class="CheckoutBtn"><?php _e('Update Profile »', 'cp')?></p>

    <!--<h2 class="h2top">Personal Information </h2>
    <table class="form-table" style="640px;">-->
    <?php
    do_action('profile_personal_options');
    ?>
    <!--</table>-->
    <h2 class="h2top"><?php echo $GLOBALS['_LANG']['_password']; ?></h2>
    <table class="form-table" style="640px;">

    <?php
    $show_password_fields = apply_filters('show_password_fields', true);
    if ( $show_password_fields ) :
    ?>
    <tr>
    <th><label for="pass1"><?php _e('New Password','cp'); ?></label></th>
    <td>
    <input type="password" name="pass1" class="mid2" id="pass1" size="35" maxlength="50" value="" />
    <small><?php _e('Leave this field blank unless you\'d like to change your password.','cp'); ?></small>
    </td>
    </tr>
    <tr>
    <th><label for="pass1"><?php _e('Password Again','cp'); ?></label></th>
    <td>
    <input type="password" name="pass2" class="mid2" id="pass2" size="35" maxlength="50" value="" />
    <small><?php _e('Type your new password again.','cp'); ?></small></td>
    </tr>
    <tr>
    </tr>
    <?php endif; ?>
    </table>

    <p class="CheckoutBtn"><?php _e('Update Profile »', 'cp')?></p>
    <?php
    if(function_exists('userphoto_exists')){
    echo '<h2 class="h2top">Website Photo </h2>
    ';
    do_action('show_user_profile');

    echo "<div id='user-photo'>";
    if(userphoto_exists($user_ID))
    userphoto($user_ID);
    else
    echo get_avatar($userdata->user_email, 96);
    echo "</div>";
    ?>
    <?php if($userdata->userphoto_image_file): ?>
    <table class="form-table" style="640px;">
    <tr>
    <th> </th>
    <td>
    <p><label><input type="checkbox" name="userphoto_delete" id="userphoto_delete" /> <?php _e('Delete existing photo?','cp') ?></label></p>
    </td>
    </tr>
    </table>
    <?php endif; ?>
    <p class="CheckoutBtn"><?php _e('Update Profile »', 'cp')?></p>
    <?php } ?>
    </form>
    -------------------------------------------------------------------
    4.) Create a page in the admin and use the 'My Account' as template.
    -------------------------------------------------------------------
    5.) Lastly, you need to add additional function under functions.php. Paste the following code.
    // checks they are authoized
    function auth_redirect_login() {
    $user = wp_get_current_user();
    if ( $user->id == 0 ) {
    nocache_headers();
    wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
    exit();
    }
    }
    ------------------------------------------------------------------
    Now its done. You may view the 'My Account' page. If youre not logged, youll be redirected to the WordPress log-in page. Once logged, youll be redirected back to the 'My Account' page. You can now view/update your profile. You can modify the following: Username, First Name, Last Name, Website URL, Bio-Info and Password.

    Hopefully this helps.

    Regards,
    Jimzqui

  9. digitalmohawk
    Member
    Posted 4 years ago #

    Hello jimzqui!! I am dying to have this option for wordpress. I am trying to follow your tutorial but somehow i get error at the start of the code

    Fatal error: Call to undefined function auth_redirect_login() in /home/wishonli/public_html/wp-content/themes/Wish/myaccount.php on line 5

    Maybe you have some idea. thanks in advance!!

  10. Chintaru
    Member
    Posted 4 years ago #

    jimzqui, you're made of absolute win. One comment though: The "Update Profile" buttons don't work for me and I got an error on the resume part (which I removed anyway since I don't use it). Other than that: you're awesome :D

  11. alexisonfire
    Member
    Posted 4 years ago #

    does anyone know how to get the Update Profile buttons to work? i've been playing with them for the last 2 days and cant seem to get them to work. any help is deeply appreciated.

  12. Chintaru
    Member
    Posted 4 years ago #

    I just turned them into this:

    <input type="hidden" name="action" value="update" />
    <input type="hidden" name="user_id" id="user_id" value="1" />
    <input type="submit" class="button" value="Update Profile" name="submit" />

    The upload User Photo form doesn't work though.

  13. mongobread
    Member
    Posted 4 years ago #

    I'm having this problem instead...

    Fatal error: Call to undefined function get_cimyFieldValue() in .../plogin.php on line 212

    with this line:

    $value = get_cimyFieldValue($user_ID, 'RESUME');

    I've been googling no relative topic.

  14. brenjt
    Member
    Posted 4 years ago #

    mongobread

    To remove that error install a plugin called
    Cimy User Extra Fields for WordPress

    And you should be good

  15. mongobread
    Member
    Posted 4 years ago #

    thanks brentjt

    Good day I bumped into this topic again

    It's working now...

    I didn't get the part where I should install first Cimy User Extra Fields plugin.

  16. floretti
    Member
    Posted 4 years ago #

    Thanks jimzqui, you offered a fine solution to my problem, although I had to make few modifications to get the extra fields (created by Cimy User Extra Fields plugin) work properly:

    1. Passing the user id

    <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />

    changed to

    <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_ID; ?>" />

    2. Right names for extra fields

    <td><textarea name="RESUME" class="mid2" id="resume" rows="8" cols="50"><?php echo cimy_uef_sanitize_content($value); ?></textarea>

    changed to

    <td><textarea name="cimy_uef_RESUME" class="mid2" id="resume" rows="8" cols="50"><?php echo cimy_uef_sanitize_content($value); ?></textarea>

    3. Submit buttons

    <p class="CheckoutBtn"><?php _e('Update Profile ยป', 'cp')?></p>

    changed to

    <input type="submit" class="button" value="Update profile" name="submit" />

  17. ngn-rashell
    Member
    Posted 4 years ago #

    has anyone figured out how to get the "User Photo" plugin to actually work with this form?

  18. sheyes@s-heyes.com
    Member
    Posted 4 years ago #

    Im having the same problem...I've got everything to work but the "User Photo" wont upload. It will from within the wordpress admin panel but not not form the code kindly shared by jimzqui

  19. sheyes@s-heyes.com
    Member
    Posted 4 years ago #

    Also, Does anyone know how to get the textarea-rich to work with jimzqui code? the text box appears but not the textarea-rich features...

Topic Closed

This topic has been closed to new replies.

About this Topic