Support

Search results for ""

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

Sort custom date field issue

Hello,

i have added a custom date field column that is store like this in the database = “22/07/2017” (d/m/Y).

On the settings of the column I found my field in the custom field list.

I set the format to d/m/Y (as in DB) and in the user list I found result with format : “m/d/Y” so often the date isnt supported because it’s not at the good format.

Could you help me with that issue ?

Thanks

6 years, 3 months ago
Stefan van den Dungen Gronovius
Developer

Hello,

Unfortunately your date format in the database is not optimal to work with in code. Our custom field column with date format tries to parse any date in the data to a timestamp to work with. Your date format is as you already notices parsed as m/d/Y. At this moment there is not much that you can do to make it work with our plugin unless you change the format of all your dates in the database. Of course, this would require quite some work on your side but I also think it easier to work with a format like a Timestamp, Y-m-d to sort etc on the front-end as well.

Another solution on our side would be that we create a new setting where you can set the format that is stored in the database, but that would also make the column more complex to work with. It is something on our radar though but we’re not sure yet how to tackle this issue.

6 years, 3 months ago
moi35200

Hello,

i’m interested in your solution, because all my dates are store like this and works fine qith ohter plugins i use.
Because if i change the format for your plugin i hve to modify it for all others + DB.

Could you add a parameter like you said ?
That could save me ! :)

Thanks in advance.

6 years ago
moi35200

Hi,

Thx for your anwser,
if I use your code my date will be shown in the right format and the sorting will work with my new format in the user list ?

I try it but without success you hook don’t seems to be call. I tried some php die
:

Here’s my code :
function aca_export_custom_field_date_format( $value, $column, $post_id ) {

die(‘Testing’);

{…}

return $value;
}

add_filter( ‘ac/export/value’, ‘aca_export_custom_field_date_format’, 10, 3 );

and i don’t have the die with “Testing”

5 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

It seems that there is a typo in the add_filter() method.
The correct filter is ‘acp/export/value’
I expect that that should cause the hook to fire.

5 years, 11 months ago
moi35200

I changed it, but is still can’t see my testing message.

I see in parmeters post_id or i’m querying the wp_users could it be the problem ?

5 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

Sorry, I was wrong. The filter was correct, ‘ac/export/value’ is correct. The title of the documentation was misleading, so I changed that in the documentation.

The actual export call is done by Ajax, so you will never see your die on the screen. Instead, you could have a look at your console and check the response of the Ajax call. You can find the ‘Testing’ string there if you hook is correctly fired.

5 years, 11 months ago
moi35200

I still can’t see anything on my XHR Response of admin-ajax.php
I have 3 calls in AJAX but none had my testing text in response.

The function is in my child theme in the functions.php file.

I don’t know what to do to try to get it work

5 years, 11 months ago
moi35200

I’m still trying to resolve the problem and when i’ve just seen in documentation that there is a hook : ac/column/value

I mean i don’t want to export the users just to shos them in the backoffice list of users with the right date and the right sorting on the date.

So i tried this solution with a string ‘Testing’:
the code never go through the “if ( $column instanceof ACP\Column\CustomField ) {”

if i put it before, every column get my string but inside the if there are no columns concerned.

Thanks in advance

5 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

I send you an email with some information. Maybe you can try to contact me on the live chat on our website so can work on this issue hands-on.

5 years, 11 months ago

You must be logged in to reply to this topic.