WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problem with update_usermeta (I think it's the colons) (2 posts)

  1. davist11
    Member
    Posted 5 years ago #

    I am working on trying to integrate wordpress and bbpress and came across a problem where when people were registering through wordpress, it was not giving them capability to post to the bbpress install. So I created a small plugin that adds the necessary meta key and value for bbpress.
    Here is the plugin code:

    function insertbbPressRole($insert_id) {
    	update_usermeta($insert_id,'bb_capabilities','a:1:{s:6:"member";b:1;}');
    }
    
    add_action('user_register', 'insertbbPressRole');

    But, the value it is actually inserting into the db is
    s:23:"a:1:{s:6:"member";b:1;}";

    It makes no sense at all. I think I have tracked it down that the colons are causing the issue. I tried escaping them, and running various functions on the string before inserting it, but to no avail.

    Anyone know why this is happening?

  2. davist11
    Member
    Posted 5 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