• Resolved sghod1212

    (@sghod1212)


    I’m creating a custom user profile page for users of my site, and I want the users to be able to update the information that is shown on these pages. I’m creating a custom page to update their information, but I don’t know how to get wordpress to reflect the changes. Some of the information that I want users to be able to change is their user bio, email, and website. How do I go about doing this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    WordPress stores all the user details in wp_users table of wordpress database…so you need to use update query on that database to alter teh details…

    However, user can also change their details from wordpress admin -> profile section..but username can not be changed.

    Thanks,

    Shane G.

    Thread Starter sghod1212

    (@sghod1212)

    Thank you very much! $wpdb->update() worked, but it led to another problem. Every apostrophe gets a backslash added to it, and every time a backslash updates the number of backslashes doubles. Example:

    Initial value: “This isn’t working.”
    1st update: “This isn\’t working.”
    2nd update: “This isn\\’t working.”
    3rd update: “This isn\\\\’t working.”
    4th update: “This isn\\\\\\\\’t working.”
    and so on…

    I would do stripslashes() but I’d like for users to be able to use slashes in their profiles.

    Can you show us the code you use to retrieve the data?

    Thread Starter sghod1212

    (@sghod1212)

    if ($_GET[‘update’] == true && $_POST[‘description’])
    {
    $description = $_POST[‘description’];
    $wpdb->update( $wpdb->usermeta,
    array( ‘meta_value’=>$description ),
    array( ‘meta_key’=>’description’,
    ‘user_id’=>$curauth->ID ));
    }

    Thread Starter sghod1212

    (@sghod1212)

    Sorry, the last post was the code I used to update the data – not retrieve it. To retrieve it I simply do this:

    $the_user = get_query_var(‘username’);
    $curauth = get_userdatabylogin($the_user);
    echo $curauth->user_description;

    The reason i ask is because i’d guess that the slashes are being added on when the data is retrieved, but then when you update the newly added slashes are added on each time…

    I’ll have a test with some code before bed or maybe tomorrow and let you know what i find…

    Thread Starter sghod1212

    (@sghod1212)

    I’m thinking that the issue deals with escape sequences somewhere in php or wordpress. When an apostrophe is put in the database something puts a backslash in front of it because it thinks that an escape sequence is necessary for the apostrophe to show up, but since the escape sequence is unnecessary the backslash and the apostrophe actually show up on the page. The next time a backslash is updated the number of backslashes doubles because a backslash would be put in front of every backslash as an escape sequence. I’m not sure if this is the issue, but if it is I’m still not sure how to go about fixing it.

    Thread Starter sghod1212

    (@sghod1212)

    So I didn’t find a solution, but I did find a workaround. I ran str_replace(“\'”, “‘”, $description); before displaying the user’s description, and then I ran the same code again before displaying the description in an edit box. PHPMyAdmin still shows the backslashes, but the users will never know.

    Ok, when the profile (or whatever) is first updated, does the database entry show a back slash?…

    If no, then it’s obvious the slashes are being added when data is retrieved, if Yes, then the slashes are being added on input…

    You’re right though, there’s just some escpaing or add slashes going on where it’s not wanted… it’s a matter of narrowing down where…

    If the str_replace is ok with you, then there’s nothing wrong with using that method…

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to change user information?’ is closed to new replies.