Adding/Joinging {usermeta} to SQL query on Members List Page
-
Hello,
I have submitted a request, see below;
I’ve been doing some development for a client, and have utilised your plugin, however I need to add custom functionality to add custom columns to the members list.
I managed to do this using the actions and filters provided (‘pmpro_memberslist_extra_cols_header’ & ‘pmpro_memberslist_extra_cols_body’), adding the PHP to the custom theme I am building, as I wanted to add usermeta data as a column – no worries there.
The issue I had was adding custom filter to filter the members list page, I successfully added a new URL parameter like this;
?page=pmpro-memberslist&domain=air
Where usermeta ‘domain’ = ‘air’
So what I had to do is edit the plugin directly, on lines 69 (where $s is set) and 95 (where $s is not set) where the SQL begins. I had to add a JOIN left for the usermeta table.
I also had to move your filter ‘$sqlQuery = apply_filters(“pmpro_members_list_sql”, $sqlQuery);’ to before the ‘GROUP BY’ section of the SQL queries in both conditional cases of $s – i.e I had to add it twice in the if/else of $s.
The reason for this is that the filter ‘pmpro_members_list_sql’ does not accommodate for this for adding in this query. I could not add my LEFT JOIN in the correct place, or my WHERE / AND as the filter is only at the end of the query.
Alternatively I could have done a string replace in the filter provided but this seems less viable than JOINING the usermeta table to the query and moving the filter for any developers who would like to add this kind of functionality in a conventional way.
Kind Regards,
- The topic ‘Adding/Joinging {usermeta} to SQL query on Members List Page’ is closed to new replies.