Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics

Filtering custom columns


I have created a custom column with your toolkit (
I’m trying to figure out how to filter a custom column that I created…

In my ac-column-my_niveau_adhesion.php the code is very simple, it’s a SQL query that retrieve the value of membership level for a user.

public function get_raw_value( $user_id ) {

		// put all the column logic here to retrieve the value you need
		// For example: $value = get_user_meta( $user_id, '_my_custom_field_example', true );
		global $wpdb;
		$value = $wpdb->get_var( $wpdb->prepare("SELECT name FROM $wpdb->pmpro_membership_levels AS level INNER JOIN $wpdb->pmpro_memberships_users AS user ON = user.membership_id WHERE user.user_id = %s ORDER BY DESC LIMIT 1", $user_id ) );

		return $value;

So it creates me a custom column with corrects values, and I can see it in the Admin Column Pro Settings.

However, the column is not ‘filterable’ as you can see…
And I don’t know how to manage this, in the ‘acp-column-my_niveau_adhesion.php’ both editing and sorting have an interface..but no filtering.

Thanks you

5 years, 1 month ago
Stefan van den Dungen Gronovius

We did not (yet) added Filterting and Smart Filtering to the toolkit yet, because these additions are quite more difficult to implement than the Editing, Sorting and Export models. Especially since filtering requires the dev to alter the WP_Query.

And based on the type of data you want to filtering, you might want to use SQL, meta_query, tax_query, date_query to alter the WP_Query. I made a quick Word in Progress change in our toolkit under a different branch.

I hope that this information will get you started writing your own models for filtering / smart filtering.
The main class now implement two new interfaces (Filterable and Searchable) with the corresponding methods (filtering and search).

In your case, you might want to alter the WP_Query by adding a join statement and where statement.

5 years, 1 month ago

You must be logged in to reply to this topic.