I am trying to filter out results of a MySQL query. I am pulling data from a Wordpress database. Specifically, I am trying to pull just the user role.
In Wordpress, the returned value is something like this:
a:1:{s:13:"administrator";s:1:"1";}
All I want to see returned is the "administrator", "author", "subscriber", etc, and not all the other information.
From my understanding (I am very much a beginner however), I can't use a substr() because the length of characters is different, and the information before the role varies as well.
Is there anyway to filter out all the other information and just return "administrator" in the MySQL query directly?
Here is my current query (I am also pulling names, email address, passwords, etc from another table):
SELECT wp_users.ID, wp_users.user_email, wp_users.user_pass, wp_users.display_name, wp_usermeta.user_id, wp_usermeta.meta_value
FROM wp_users
JOIN wp_usermeta
ON wp_users.ID = wp_usermeta.user_id
WHERE (wp_usermeta.meta_value LIKE '%admin%')
OR (wp_usermeta.meta_value LIKE '%author%')
OR (wp_usermeta.meta_value LIKE '%subscriber%')
SELECT wp_users.display_name FROM wp_users JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id WHERE (wp_usermeta.meta_value LIKE '%admin%') OR (wp_usermeta.meta_value LIKE '%author%') OR (wp_usermeta.meta_value LIKE '%subscriber%')