Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › How to drop wordpress cache
New Landing › How can we help? › Themeforest Theme Support › Dante › How to drop wordpress cache
- This topic has 8 replies, 3 voices, and was last updated 9 years by Rui Guerreiro – SUPPORT.
-
Posted in: Dante
-
November 6, 2015 at 4:55 pm #226729
Hi,
My question might be beyond the scope of your support but I just wanted to ask you for your feedback anyway.
I have imported 4000 customers to the website of my client from a csv file that contained, apart from normal wordpress fields (username, first_name etc), custom fields. I wanted to display one of those custom fields (called Certificazione) with every new order email.
So I created a child theme and added the admin-new-order.php inside and included the following code:<?php global $current_user; get_currentuserinfo(); echo 'Certificazione: ' . $current_user->Certificazione . "\n"; ?>
When I test the code with my admin account it works correctly and displays the “Certificazione” field. When one of the imported customers proceeds with an order, in the email I receive the Certificazione field appears empty.
I can’t really figure out why this is happening so I am guessing it is a caching issue. I have tried to install a lot of different plugins to clear the cache but non of them worked. I did some digging and I figured out that my client is using a server that runs Windows NT!!! Is there a way to drop the cache in such a server in your opinion?
I would really appreciate it if you could give me some feedback.
Thanks a lot for your time.
Attachments:
You must be logged in to view attached files.November 6, 2015 at 5:24 pm #226745Hi,
As this is not a theme issue, I cannot help as such. I can offer some thoughts:
1) Did you use a plugin to create the custom field, or your own function?
2) Are you sure the new field
Certificazione
is not actually calledcertificazione
.3) Have you tried debugging this further by actually passing a user id of a customer into the
get_currentuserinfo()
function to see what this output’s?4) A concern that you should investigate is, this function
get_currentuserinfo()
returns the details of a current logged in user.get_user_meta
may well be better https://codex.wordpress.org/Function_Reference/get_user_meta– I think the best place for this query would be StackOverflow.
Cheers,
David.November 6, 2015 at 5:40 pm #226759Hi David and thanks for your time.
1) I have used a plugin called “Import users from CSV with meta” to upload the csv file that contained the normal wordpress fields like username, first_name, last_name as well as custom fields (one of them was “Certificazione”). When users were imported the custom fields were created in the wordpress backend in the profile of each user. I personally went to phpMyAdmin database and checked if they were also imported there and they are in fact in there as well.
2) I have checked and I confirm that the field is Certificazione with capital “c”.
3) I haven’t tried this as the website is already live and I wouldn’t want to make an order at this time. As I mentioned the code works if I do an order with my admin account and it also works if I create a new user and make an order with this new account. I suspect that if I go to a user’s profile and I edit it and save it next time he/she makes an order the field will be displayed with the email but I can’t physically go through 4000 users and update them.
4) I haven’t tried that as I am not really familiar with PHP coding but I will give it a try. I have already posted in stackoverflow 10 days ago with no luck whatsoever. I have now created a bounty there to offer reputation in order for someone to help me faster.
One thing that came to my mind is that my client is running windows NT server. I read online that MySQL databases don’t behave properly when in windows servers. I read somewhere that you might have to convert them to .SQL but I am not sure if this is the case. What is your opinion on that? I will try and investigate further.
Thanks a lot for taking the time to answer this. I really appreciate it!
November 6, 2015 at 5:52 pm #226763No problem, the issue is likely overly simple.
I suggest you hire a web developer as I would not think this should be a massive task.
Do also check the users exist in the WP users dashboard and try to pass a user ID to your code and test what
$current_user
contains.Thanks,
David.November 6, 2015 at 6:16 pm #226775Thanks David,
I am sure it’s something simple as well and it’s really frustrating! I am sure someone with good PHP skill will be able to resolve this easily. I tried asking for a Quote from a third party agency Swiftideas suggested me about a week ago but they don’t take projects under 5K!!!
I have posted in several places now and I hope I find someone to hire and help me at an affordable rate.
Once again, thanks a lot for your time.
November 6, 2015 at 6:22 pm #226776I would really suggest setting up a test/dev site for you to run these tests on.
I would create a test case using https://codex.wordpress.org/Function_Reference/get_user_meta.
With the below you can change the
$user_id
to first your own, then the imported users and see what is returned.<?php $user_id = 9; $key = 'Certificazione'; $single = true; $user_last = get_user_meta( $user_id, $key, $single ); echo '<p>The '. $key . ' value for user id ' . $user_id . ' is: ' . $user_last . '</p>'; ?>
Thanks,
David.November 6, 2015 at 8:40 pm #226793Hi David,
As I said the problem appears only when the imported users proceed with a purchase. So even if I create a test site I wouldn’t be able to check it as I would have to import them in the dev site and if I make an order through them they would be notified through email notification.
I have tested the code you provided by adding it to display in “My Account” page. It is shows the Certificazione correctly as I have set it in my profile. I then tried changing the user_id with one of a different user that has different Certificazione type than mine and it also shows correctly under “My Account” page, which means the code is working.
I checked the database again using this code:
SELECT * FROM
wp_usermetaWHERE meta_key = 'Certificazione' and meta_value = ''
to check for users that had an empty value in this field and it only found 1 user when I know for a fact (from the csv file I uploaded) that there are 13 users with no value in Certificazione. This 1 user I searched him in wordpress and when I entered his profile the “Certificazione” field wasn’t empty and it had in fact something inside which is weird. I then updated this user by clicking “Update User” at the end of the page and when I checked back the database it wasn’t empty anymore and the MySQL code I used above now returns 0 which means it still can’t find the remaining users but the one I updated was registered in the database.
I still find this really confusing and i hope I can find someone to help me with this issue.
Cheers.
November 6, 2015 at 11:20 pm #226802Just to give you an update,
Since some of those customers have multiple accounts and they use the same email address I also used a plugin called “Allow multiple Accounts”.
My problem was that 960/4000 users didn’t contain an email address (!!!).
I went to phpMyAdmin and searched for all users that don’t have anything in field “Certificazione” and I found 10 of them out of 4000.
I went to their profile in WP and I updated one by one by entering their profile and clicking update user.
When I updated one I did the following search in MySQL:SELECT * FROM
wp_usermeta
WHERE meta_key = ‘Certificazione’ and meta_value = ”To my surprise it was showing a user ID that even though the Certificazione field in WP was set it appeared empty in the database.
So for each update of the 10 users that had no Certificazione field there was a corresponding user ID that even though it had a value in Certificazione in WP it appeared empty in the database after the update of the previous user.
It’s a bit hard to make it clear but it seems like the user ID’s that appeared empty they all had no email address set!So I did a custom search to find which fields they didn’t have an email address using this code:
SELECT * FROM
wp_users
WHERE user_email = ”and all 960 appeared. I then decided to set a custom email address to all of them to try and find out if this is what causes the problem so I used the following code:
UPDATE wp_users SET user_email=’[email protected]’ WHERE user_email=”
I will now have to wait until another customer makes an order to see if this was causing the issue.
I am just writing here what I am doing in case someone has a similar issue in the future so they can figure it out faster.
Fingers crossed.November 9, 2015 at 1:35 pm #227033Ok. Thanks for the information.
Good luck.-Rui
-
Posted in: Dante
You must be logged in and have valid license to reply to this topic.