update_usermeta broken? (3 posts)

  1. rbendig
    Posted 8 years ago #


    the past few days i tried to setup some roles via scripting.

    there i found that (i do not know, how to set roles via code, the codex gives nothing about that, i just did a grep about the code, and looking at mysql.log while updating some roles via wp-admin)

    if i try to update with a value "{s:13:"administrator";b:1;}" it does, if i am using "a:1:{s:13:"administrator";b:1;}" it breaks the value and will add "s:31:\"" in front of the value ;-((

    so i cannot insert the right value "´a:1:{s:13:"administrator";b:1;}´" into the database, it comes there as s:31:\"a:1:{s:13:"administrator";b:1;}

    how can i fix that behavior? or how can i add roles to users via code? ;-)

  2. davist11
    Posted 7 years ago #

    I am having a very similar problem. I am trying to insert a:1:{s:6:"member";b:1;}, and it is inserting it as s:23:"a:1:{s:6:"member";b:1;}";

    Was there any solution to this?

  3. davist11
    Posted 7 years ago #

    Ok, so I found the solution. I just had to run the string into the maybe_unserialize function and it inserted it correctly.

Topic Closed

This topic has been closed to new replies.

About this Topic