Shane
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
America/Jamaica (GMT-05:00)
Hi Julie,
I see the problem now. With custom-field-2 it wasn't created in Types. It was manually created through the database. In order for you to use the types shortcode to get the user fields. They must be fields that were created using Types.
If the field was not created using Types then you will need to use a custom shortcode as you did to retrieve the field. I was under the impression that both fields were created with Types.
Thanks,
Shane
I was under the impression that both fields were created with Types
I told you 6 days ago here https://toolset.com/forums/topic/wpv-conditional-shortcode-using-custom-user-field-not-working/#post-1091097 how the fields had been created (one via registration form, one not). I'm struggling to comprehend where your impression has come from.
I'm of the opinion that in the past the Types conditional shortcode worked with custom user fields no matter how they were created.
Even if that opinion is incorrect, there is an issue in the long term here; if I introduce a new custom user field at some point (and update registration forms accordingly for future new users), those fields need to be "applied" to existing Users without requiring any action by the Users themselves so that the wpv-conditional shortcode using the custom field works for ALL Users.
Please advise how this can be achieved.
Shane
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
America/Jamaica (GMT-05:00)
Hi Julie,
It seems that because of the use of the wpcf- prefix on the custom field , I automatically assumed that it was created in Types and you were using some custom hook to populate the field or entering the field data manually in the database.
Actually this sort of behaviour is expected because if types is referencing the fields that it created by using the internal reference. Example when you go to the backend under the custom field settings you will see the fields created there.
Only fields created with Types can use the [types field='my-field'][/field] shortcode. If the field was not created using Types and was done by a manual creation such as manual database entry or hook then the views shortcode [wpv-user] would be the best solution to use.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-154505
This shortcode is made specifically for a case like this. If the field was created in Types and you then manual add it to the database then the Types shortcode would've worked since there is a reference to it in Types.
It was until I checked Types that I realised that the field was not created there. I must apologize for not realising this sooner.
Please let me know if this clears things up a bit for you.
Thanks,
Shane
I've tested using wpv-user and I can confirm this returns the value of the custom user field irrespective of the way the field was created.
However, I have NEVER EVER used wpv-user before yet I've played around with custom user fields plenty and frequently add them manually whilst testing before updating registration forms. This strengthens my belief that this has not been an issue previously so something has changed.
You've not addressed my question about getting new custom user fields to work for existing users.
I think this needs to be escalated to the developers please.
Shane
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
America/Jamaica (GMT-05:00)
Hi Julie,
These new custom fields you create if not created using Types then they won't be able to be retrieved using the Types shortcode as you mentioned in the previous post.
Your initial post made mention that the types field does not retrieve your custom fields. I did a check on the duplicator and I found that these fields were not Created using Types.
The Types shortcode has never worked as far as I can recall with fields that were not created with out Types plugin. What might've happen in the past for you is that you created the fields using Types and then manually populate the fields using a Hook or entered manually in the database.
Can you confirm that you are creating the custom fields through the database and not through Types?
Thanks,
Shane
You are still not taking on board what I've already told you and still haven't addressed the issue of getting new custom user fields to work with existing users.
I've worked out that there IS a solution to associating new custom user fields for existing users which actually then also solves the issue I was having originally with the wpv-conditional shortcode.
Since I've worked this out for myself, I'm closing this ticket.
PS: it's my understanding that the types shortcode is [types field='my-field'][/types] not [types field='my-field'][/field]