Ordering a serialized custom field
-
Hi,
I’m using s2member to allow different user levels, custom registration fields, etc.
Now I need to show a user list ordered by a s2member custom field.
As far as I know s2member is storing the custom fields serialized so It’s hard to me to know how I can order the list depending on a custom field.For example, in wp_usermeta where the meta_key =
wp_s2member_custom_fields
and the meta_value =a:17:{s:8:"telefono";s:11:"917 004 850";s:3:"fax";s:9:"9130838XX";s:5:"cargo";s:17:"Project Developer";s:9:"email_web";s:19:"[email protected]";s:12:"razon_social";s:31:"ACTIVOS EN RENTA 123456789";s:16:"nombre_comercial";s:25:"ACTIVOS EN RENTA 123456";s:9:"direccion";s:23:"C/ General Casta?os";s:13:"codigo_postal";s:5:"28XXX";s:9:"localidad";s:6:"Madrid";s:9:"provincia";s:6:"Madrid";s:16:"asociado_miembro";s:8:"24242424";s:9:"categoria";s:1:"X";s:11:"actividades";a:1:{i:0;s:8:"Promotor";}s:15:"grupo_actividad";s:10:"Promotores";s:19:"actividad_principal";s:56:"Promoción y Desarrollo de plantas solares Fotovoltaicas";s:18:"comunidad_autonoma";a:2:{i:0;s:14:"CastillaMancha";i:1;s:12:"CastillaLeon";}s:21:"actividad_exportadora";s:2:"No";}
So the query I must code would be something similar to
$query = "SELECT $wpdb->users.ID, $wpdb->users.user_nicename FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $meta_values ORDER BY <strong>s2member_custom_fields['nombre_comercial']</strong> LIMIT $offset, $limit";
Can anybody help me?
Thanks.
- The topic ‘Ordering a serialized custom field’ is closed to new replies.