Support

Search results for ""

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

Creating a new field & applying sorting (to users)

Hey,

I’ve created a new column type using the Admin Columns Pro example, it essentially joins a post type to the users views. (Users have a meta field which contains an ID of a custom post, this custom post has value which is displayed in the new column)

All working fine for displaying and sorting this column but I can’t seem to get my head around the logic of filtering (smart or standard) for this.

For smart filtering I can’t seem to find a “user” binding, only POST, MEDIA, and COMMENT ($binding = new \ACP\Search\Query\Bindings\Post())

For standard filtering it looks like the $this object is a standard WP_Query whereas I need to access the WP_User_Quer ideally.

Any help is greatly apreciated.

Cheers, Tom

10 months, 1 week ago
Stefan van den Dungen Gronovius
Developer

Hi Tom,

Just to be sure, weren’t you able to use the Custom Field column on the user list table that shows the related Post Type? When a user has a custom field that stores a post ID, you should be able to configure the Custom Field column to show information from the related post. In that case, you’ll set the Field Type to ‘Post’ and all pro feature also automatically work.

You can btw, just use the Default Binging class as it will work for all meta types. You can use the join methods to add a custom inner join to make it work.

I hope that this helps you to proceed with your custom code if the Meta column as suggested above does not work for you.

10 months ago
hello36

Hi Stefan,

Thanks for this, using custom field > type (Post) I can only get the related post Title / ID etc out of the box, I need to get a meta field within the related post.

Thanks for this, it must be something not quite configured right with the Query in the sorting function at my end as I can’t seem to get it to return anyting from the users table.

I’ll have another play with it and see if I can make any progress.

Cheers, Tom

10 months ago
hello36

Hi Stefan,

I’ve still not had any luck getting this to work, I can’t find any documentation on the binding class and can’t seem to achieve what I need.

Default custom field types (with a relationship field) do not help with this as I need to get a meta value from the related post type not just a title or ID.

Setup is as follows:

Users have a meta key of “organisation” which stores a meta value of a related post ID for an “orgnaisation” post type

Organisation post types have a meta key of “Region”, this meta value within the related Organisation is the one I require to be filterable.

User (wp user) > Organisation (POST TYPE) > region (META VALUE on Organisation)

I can inspect the function and get the Operator, values and provided binding but I can’t seem to use this with any success adding in attrs to the binding in any useful way to search for a wordpress post.

For an idea I’ve use the following with no luck:

`
// Example #1 – altering the \WP_Meta_Query
$binding->meta_query( [
‘key’ => ‘region’,
‘value’ => $value->get_value(),
‘compare’ => $operator,
] );
`

Thanks in advance, Tom

9 months ago

You must be logged in to reply to this topic.