Home › Types Community Support › [Resolved] types_render_usermeta_field unable to select for specific user (id)
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 18:00 | 9:00 – 18:00 | 9:00 – 18:00 | 9:00 – 18:00 | 9:00 – 18:00 | - |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
Tagged: Setting up custom fields, Types plugin
Related documentation:
This topic contains 6 replies, has 2 voices.
Last updated by davidJ-6 9 years, 1 month ago.
Assisted by: Waqas.
I'm using Easy Digital Downloads with Marketify theme.
Types is allowing me to pull custom field information correctly and works wonderfully.
However, I am unable to pull a User custom field from one particular template, the EDD receipt (shortcode-receipt.php)
This is the code I'm using
<tr> <td><strong>Picked up from:</strong></td> <td><?php echo(types_render_usermeta_field( "suburb", array("user_id" => $user['id'])));?></td> </tr>
I have this working from another template without having to specify the user_id so I know the 'suburb' field is accessible with Types.
I also know the $user['id'] is correct as when I echo directly I get the correct user id which is 4.
If I hard code "user_id" => 4 this doesn't work either.
Not really sure what I'm doing wrong.
Any advice appreciated.
Thanks,
David.
Just realised where to find debug info so pasted below.
Still unable to resolve. I even tried hard coding the user id on the product listing but it displays a blank suburb. Simply seems the user_id => isn't working.
{"core":{"Wordpress":{"Multisite":"No","SiteURL":"http:\/\/usemybag.com.au","HomeURL":"http:\/\/usemybag.com.au","Version":"4.1.1","PermalinkStructure":"","PostTypes":"post, page, attachment, revision, nav_menu_item, wp-types-group, wp-types-user-group, edd_log, download, edd_payment, edd_discount, fes-forms, store_page, tt_font_control","PostSatus":"publish, future, draft, pending, private, trash, auto-draft, inherit, refunded, failed, revoked, abandoned, active, inactive"},"Server":{"jQueryVersion":"1.11.1","PHPVersion":"5.5.17","MySQLVersion":"5.5.39","ServerSoftware":"Apache"},"PHP":{"MemoryLimit":"256M","UploadMax":"100M","PostMax":"100M","TimeLimit":"120","MaxInputVars":"2000"}},"plugins":{"active_plugins":{"advanced-code-editor\/advanced-code-editor.php":{"Name":"Advanced Code Editor","PluginURI":"http:\/\/en.bainternet.info","Version":"2.2.6","Author":"BaInternet","AuthorURI":"http:\/\/en.bainternet.info","TextDomain":"","DomainPath":"","Network":false,"Title":"Advanced Code Editor","AuthorName":"BaInternet"},"baw-login-logout-menu\/bawllm.php":{"Name":"BAW Login\/Logout menu","PluginURI":"http:\/\/www.boiteaweb.fr\/llm","Version":"1.3.2","Author":"Juliobox","AuthorURI":"http:\/\/www.boiteaweb.fr","TextDomain":"","DomainPath":"","Network":false,"Title":"BAW Login\/Logout menu","AuthorName":"Juliobox"},"easy-digital-downloads-frontend-submissions-product-details-widget\/edd-fes-product-details.php":{"Name":"Easy Digital Downloads - Frontend Submissions Product Details","PluginURI":"https:\/\/github.com\/astoundify\/edd-fes-product-details","Version":"1.0.2","Author":"Astoundify","AuthorURI":"http:\/\/astoundify.com","TextDomain":"","DomainPath":"","Network":false,"Title":"Easy Digital Downloads - Frontend Submissions Product Details","AuthorName":"Astoundify"},"easy-digital-downloads\/easy-digital-downloads.php":{"Name":"Easy Digital Downloads","PluginURI":"http:\/\/easydigitaldownloads.com","Version":"2.2.8","Author":"Pippin Williamson","AuthorURI":"http:\/\/pippinsplugins.com","TextDomain":"edd","DomainPath":"languages","Network":false,"Title":"Easy Digital Downloads","AuthorName":"Pippin Williamson"},"easy-google-fonts\/easy-google-fonts.php":{"Name":"Easy Google Fonts","PluginURI":"","Version":"1.3.5","Author":"Titanium Themes","AuthorURI":"http:\/\/www.titaniumthemes.com","TextDomain":"","DomainPath":"","Network":false,"Title":"Easy Google Fonts","AuthorName":"Titanium Themes"},"edd-featured-downloads\/edd-featured-downloads.php":{"Name":"EDD Featured Downloads","PluginURI":"http:\/\/sumobi.com\/store\/edd-featured-downloads\/","Version":"1.0","Author":"Andrew Munro - Sumobi","AuthorURI":"http:\/\/sumobi.com","TextDomain":"","DomainPath":"","Network":false,"Title":"EDD Featured Downloads","AuthorName":"Andrew Munro - Sumobi"},"edd-fes\/edd-fes.php":{"Name":"Easy Digital Downloads - Frontend Submissions","PluginURI":"https:\/\/easydigitaldownloads.com\/extensions\/frontend-submissions\/","Version":"2.2.13","Author":"Chris Christoff","AuthorURI":"http:\/\/www.chriscct7.com","TextDomain":"edd_fes","DomainPath":"\/edd_fes\/languages\/","Network":false,"Title":"Easy Digital Downloads - Frontend Submissions","AuthorName":"Chris Christoff"},"edd-hide-download\/edd-hide-download.php":{"Name":"Easy Digital Downloads - Hide Download","PluginURI":"http:\/\/sumobi.com\/shop\/edd-hide-download\/","Version":"1.2.7","Author":"Andrew Munro, Sumobi","AuthorURI":"http:\/\/sumobi.com\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Easy Digital Downloads - Hide Download","AuthorName":"Andrew Munro, Sumobi"},"edd-purchase-limit\/edd-purchase-limit.php":{"Name":"Easy Digital Downloads - Purchase Limit","PluginURI":"https:\/\/easydigitaldownloads.com\/extension\/purchase-limit\/","Version":"1.2.9","Author":"Daniel J Griffiths","AuthorURI":"http:\/\/section214.com","TextDomain":"edd-purchase-limit","DomainPath":"","Network":false,"Title":"Easy Digital Downloads - Purchase Limit","AuthorName":"Daniel J Griffiths"},"edd-reviews-change-login-message\/edd-reviews-change-login-message.php":{"Name":"Edd Reviews - Change login message","PluginURI":"","Version":"","Author":"","AuthorURI":"","TextDomain":"","DomainPath":"","Network":false,"Title":"Edd Reviews - Change login message","AuthorName":""},"edd-reviews\/edd-reviews.php":{"Name":"Easy Digital Downloads - Product Reviews","PluginURI":"http:\/\/easydigitaldownloads.com\/extension\/reviews\/","Version":"1.3.8","Author":"Sunny Ratilal","AuthorURI":"","TextDomain":"edd-reviews","DomainPath":"languages","Network":false,"Title":"Easy Digital Downloads - Product Reviews","AuthorName":"Sunny Ratilal"},"grid-columns\/grid-columns.php":{"Name":"Grid Columns","PluginURI":"http:\/\/themehybrid.com\/plugins\/grid-columns","Version":"0.2.0","Author":"Justin Tadlock","AuthorURI":"http:\/\/justintadlock.com","TextDomain":"","DomainPath":"","Network":false,"Title":"Grid Columns","AuthorName":"Justin Tadlock"},"hello.php":{"Name":"Hello Dolly","PluginURI":"http:\/\/wordpress.org\/plugins\/hello-dolly\/","Version":"1.6","Author":"Matt Mullenweg","AuthorURI":"http:\/\/ma.tt\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Hello Dolly","AuthorName":"Matt Mullenweg"},"jquery-collapse-o-matic\/collapse-o-matic.php":{"Name":"Collapse-O-Matic","PluginURI":"http:\/\/plugins.twinpictures.de\/plugins\/collapse-o-matic\/","Version":"1.6.5","Author":"twinpictures, baden03","AuthorURI":"http:\/\/twinpictures.de\/","TextDomain":"colomat","DomainPath":"\/languages","Network":false,"Title":"Collapse-O-Matic","AuthorName":"twinpictures, baden03"},"limit-login-attempts\/limit-login-attempts.php":{"Name":"Limit Login Attempts","PluginURI":"http:\/\/devel.kostdoktorn.se\/limit-login-attempts","Version":"1.7.1","Author":"Johan Eenfeldt","AuthorURI":"http:\/\/devel.kostdoktorn.se","TextDomain":"limit-login-attempts","DomainPath":"","Network":false,"Title":"Limit Login Attempts","AuthorName":"Johan Eenfeldt"},"login-screen-manager\/login-screen-manager.php":{"Name":"Login Screen Manager","PluginURI":"http:\/\/www.SuperbCodes.com\/","Version":"3.0.1","Author":"Nazmul Hossain Nihal","AuthorURI":"http:\/\/www.SuperbCodes.com\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Login Screen Manager","AuthorName":"Nazmul Hossain Nihal"},"nav-menu-roles\/nav-menu-roles.php":{"Name":"Nav Menu Roles","PluginURI":"http:\/\/www.kathyisawesome.com\/449\/nav-menu-roles\/","Version":"1.6.4","Author":"Kathy Darling","AuthorURI":"http:\/\/www.kathyisawesome.com","TextDomain":"","DomainPath":"","Network":false,"Title":"Nav Menu Roles","AuthorName":"Kathy Darling"},"override-marketify-redirect\/override-marketify-redirect.php":{"Name":"Override Marketify Redirect","PluginURI":"","Version":"","Author":"","AuthorURI":"","TextDomain":"","DomainPath":"","Network":false,"Title":"Override Marketify Redirect","AuthorName":""},"peters-login-redirect\/wplogin_redirect.php":{"Name":"Peter\u0027s Login Redirect","PluginURI":"http:\/\/www.theblog.ca\/wplogin-redirect","Version":"2.8.2","Author":"Peter Keung","AuthorURI":"http:\/\/www.theblog.ca","TextDomain":"","DomainPath":"","Network":false,"Title":"Peter\u0027s Login Redirect","AuthorName":"Peter Keung"},"pluginception\/pluginception.php":{"Name":"Pluginception","PluginURI":"http:\/\/ottopress.com\/wordpress-plugins\/pluginception","Version":"1.2","Author":"Otto","AuthorURI":"http:\/\/ottopress.com","TextDomain":"pluginception","DomainPath":"","Network":false,"Title":"Pluginception","AuthorName":"Otto"},"profile-builder-hobbyist\/index.php":{"Name":"Profile Builder Hobbyist","PluginURI":"http:\/\/www.cozmoslabs.com\/wordpress-profile-builder\/","Version":"2.1.1","Author":"Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel","AuthorURI":"http:\/\/www.cozmoslabs.com\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Profile Builder Hobbyist","AuthorName":"Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel"},"profile-builder-mchl\/index.php":{"Name":"Profile Builder - Maximum Character Length Add-On","PluginURI":"http:\/\/www.cozmoslabs.com\/wordpress-profile-builder\/","Version":"1.0.0","Author":"Cozmoslabs, Mihai Iova","AuthorURI":"http:\/\/www.cozmoslabs.com\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Profile Builder - Maximum Character Length Add-On","AuthorName":"Cozmoslabs, Mihai Iova"},"profile-builder-numbers-only-field\/index.php":{"Name":"Profile Builder - Numbers and Phone Validation","PluginURI":"http:\/\/www.cozmoslabs.com\/wordpress-profile-builder\/","Version":"1.0.1","Author":"Cozmoslabs, Cristian Antohe","AuthorURI":"http:\/\/www.cozmoslabs.com\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Profile Builder - Numbers and Phone Validation","AuthorName":"Cozmoslabs, Cristian Antohe"},"redirect_aftersubmission\/redirect_aftersubmission.php":{"Name":"Redirect_AfterSubmission","PluginURI":"","Version":"","Author":"","AuthorURI":"","TextDomain":"","DomainPath":"","Network":false,"Title":"Redirect_AfterSubmission","AuthorName":""},"say-what\/say-what.php":{"Name":"Say What?","PluginURI":"https:\/\/github.com\/leewillis77\/say-what","Version":"1.1","Author":"Lee Willis","AuthorURI":"http:\/\/www.leewillis.co.uk\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Say What?","AuthorName":"Lee Willis"},"simple-custom-css\/simple-custom-css.php":{"Name":"Simple Custom CSS","PluginURI":"http:\/\/johnregan3.github.io\/simple-custom-css","Version":"3.2","Author":"John Regan, Danny Van Kooten","AuthorURI":"http:\/\/johnregan3.me","TextDomain":"sccss","DomainPath":"","Network":false,"Title":"Simple Custom CSS","AuthorName":"John Regan, Danny Van Kooten"},"store-locator-le\/store-locator-le.php":{"Name":"Store Locator Plus","PluginURI":"http:\/\/www.storelocatorplus.com\/","Version":"4.2.36","Author":"Charleston Software Associates","AuthorURI":"http:\/\/www.storelocatorplus.com","TextDomain":"csa-slplus","DomainPath":"\/languages\/","Network":false,"Title":"Store Locator Plus","AuthorName":"Charleston Software Associates"},"types\/wpcf.php":{"Name":"Types - Complete Solution for Custom Fields and Types","PluginURI":"http:\/\/wordpress.org\/extend\/plugins\/types\/","Version":"1.6.5","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com","TextDomain":"","DomainPath":"","Network":false,"Title":"Types - Complete Solution for Custom Fields and Types","AuthorName":"OnTheGoSystems"},"use-my-bag\/use-my-bag.php":{"Name":"UMB Tweaks","PluginURI":"http:\/\/www.kadimi.com\/en\/quote","Version":"1.0.0","Author":"Nabil Kadimi","AuthorURI":"http:\/\/kadimi.com","TextDomain":"","DomainPath":"","Network":false,"Title":"UMB Tweaks","AuthorName":"Nabil Kadimi"},"widget-importer-exporter\/widget-importer-exporter.php":{"Name":"Widget Importer \u0026 Exporter","PluginURI":"https:\/\/github.com\/stevengliebe\/widget-importer-exporter","Version":"1.1.4","Author":"Steven Gliebe","AuthorURI":"http:\/\/stevengliebe.com","TextDomain":"widget-importer-exporter","DomainPath":"\/languages","Network":false,"Title":"Widget Importer \u0026 Exporter","AuthorName":"Steven Gliebe"}},"mu_plugins":[],"dropins":[]},"theme":{"Name":"Marketify - Child Theme","ThemeURI":null,"Author":"\u003Ca href=\u0022http:\/\/astoundify.com\u0022\u003EAstoundify\u003C\/a\u003E","AuthorURI":null,"Template":"marketify","Version":"1.0.1","TextDomain":null,"DomainPath":null},"extra-debug":{"types":{"add_resized_images_to_library":0,"register_translations_on_import":1,"images_remote":0,"images_remote_cache_time":"36","help_box":"by_types"}}}
Can you please mention the type of the user meta field (i.e. text, URL, numeric or etc)? And also please confirm if following code works or not:
<?php echo types_render_usermeta_field( "suburb", array( "user_current" => true ) ); ?>
This code should return the value for "currently logged in" user's meta field (https://toolset.com/documentation/functions/#textfield). Also please try adding a prefix to field name as "wpcf-suburb" if it was created using Types. You can try this prefix thing with your mentioned syntax also.
Finally, can you please copy/paste the debug information in the special debug information area on this page? So I will be able to analyze it properly. I have enabled debug information area for your next reply. Please see https://toolset.com/faq/provide-debug-information-faster-support/ for more details.
Hi Waqas,
Thanks for the response, much appreciated.
I don't see a debug information area on this page, only a screen shots upload. Is there any other way to send you the debug information?
I've tried your suggestion with "user_current" => true but still nothing is appearing.
The field is a textfield and it was created using Easy Digital Downloads Front End Submissions User registration form (image attached). I passed control of this to Types. Also tried with wpcf-suburb just in case but again nothing appearing.
Thanks,
David.
Hi Waqas,
I did some more experimenting. Realising that the currently logged in user is ID 4 and my script is also looking for user ID 4, I hard coded to look for user ID 2 instead (this is actually the ID it should be looking for) and it's now finding the suburb correctly
So the issue appears to be that it's not working if the current logged in user ID is the same ID as the one I'm looking for.
In all honesty this would never happen on my site since they should be different users. Appears I'm grabbing the wrong user ID (4).
It's an issue nonetheless, but not for me anymore.
I suppose "user_current" => true not working is also an issue.
Happy to close this unless the above is still deemed a problem.
Regards,
David.
I am glad to know that you have found the cause of this problem and have resolved it.
"user_current" outputs user field for the logged in user. If the field you were looking for belongs to another user, it won't be accessible. It will also won't be accessible if current user has no such field attached (or in other words have no value available in this field - visually returning an empty value).
In short, for accessing the fields of another user, you must supply the User ID.
Thanks for clarifying and my apologies for closing this so late.
The forum ‘Types Community Support’ is closed to new topics and replies.