In this example, you can see how to add the IP column and it’s simple because the IP info is already stored in the Dashboard DB.
However to create columns that will show custom info that is not stored in the MainWP Dashboard database, such as server admin URL, Referring Domains…), first, you need to create custom site fields on the Site Edit page and enter the values, after that, you can use those hooks to show the data in the table.
By default, the new column will be included in the search feature.
However, it’s not sortable by default.
I will need to check with the dev team if this can be tweaked in the next update.
Thanks. We have added a custom field via Extensions → Pro Reports → Tokens. This custom field is not included in search feature, it is? And how can we do that?
Regarding the sorting ability of custom columns, there is another filter that can be used to add the column in the array of sortable columns, for example the IP Address column that we created in the previous example will be sortable if you use this snippet:
Regarding the search ability, the Search feature of the Manage Site table, but default, includes all data that is in the table. Maybe I am missing something in your setup. Can you please provide me with more details?
I’ve added your code to be able to sort on the custom column. After that the sort icons (ascending / descending) appear but when I try to sort on the custom column the table is not sorted. We’re using MainWP version 4.4.1 and WP 6.2.
Searching for data used in the custom field is not working. We added this custom field via extensions → Pro Reports → Tokens and added some data in the custom field for some clients. When we search on the data we get the message “No websites found” and a few seconds after this search all websites are shown again.
I’ve tested this code as well as I’m showing the IP in my table too. It does show the sort up/down icons, but it doesn’t sort anything.
I also tried to find the filter in the docs on mainwp.dev, but couldn’t find it there.
I assume you have the Optimize for Big Networks and Shared Hosting option enabled on your setup.
I reviewed the code and found that the sortable column filter is not applied in this mode.
If the option is disabled, sorting should work fine.
However, I will review this further with our dev team and have them update the “Optimized” mode too.
Yes, that option is indeed enabled. If sorting would need too much resources, it might also be an option to filter the sites based on an IP address (partial, starting with…).
I can confirm changing value for “Optimize for shared hosting or big networks” to “Off” makes it possible to sort the custom fields. But the loading of the sites table is very slow because of this. How can we improve the loading time?
The loading time is dependent on the performance of the server.
Please take a look at our help document for minimum and recommended system requirements, including some general guidelines for Dashboards with higher child site count: