This topic contains 2 replies, has 2 voices. Last updated by Jason (Lead Developer) 3 years, 11 months ago.
|Posted: Friday Jan 25th, 2013 at 10:58 am #39512|
I’m a PHP developer, tasked with creating a “members only” section of a website. I’ve found s2Member to be very useful to help eliminate the need to custom code a lot of functionality.
My only real gripe is the way that user profile information is stored in the database. Since it is stored in one field, in a serialized string format, I’m running into problems when trying to update field programmatically.
I have your typical “textfield” user profile address fields for address, city, state, zip. However the client has requested similar fields that are for “internal use only” and need to be pre-filled out with the same data that is already stored in the above mentioned fields. Since each field is stored in one big serialized array, I have no choice but to pull all of the data and re-INSERT it into the database for the additional fields instead of performing a MySQL UPDATE.
I wrote a script to do this, but the users who have special characters that need to be escaped, especially for an apostophre (‘), are coming up blank in the WP user list once imported. This is because the serialized data is considered to be invalid by PHP. For example, if we have a field that contains the value “Harry’s Boats”, the ‘ needs to be escaped, so it becomes Harry’s Boats. I’m properly escaping the ‘ using PHP’s mysql_real_escape_string() or addslashes(), but even though the DB insert was successful, the user information is suddenly blank when viewing in WP Users “/wp-admin/users.php”.
I’m not totally sure what the problem is, other than I think it may have something to do with the database not storing the correct amount of characters in the serialized array, rendering it invalid. If anybody knows what I’m talking about or has experienced this kind of problem before, please let me know. I have 1,000+ users, so I would really prefer not to go through the database manually and check them.