I am checking value of usermeta field using below condition in to content template, but it is not working, not printing any data.
[wpv-if evaluate="'[types usermeta='_new_user'][/types]' = '0'"]value is 0[/wpv-if]
Please check screenshot for the database field.
Thanks
Hi, I think your logic looks fine and the if statement seems to be using the correct syntax...so something else must be going on. Can you answer these questions for me?
- I can't tell from the screenshots, are you logged in as the User with ID 11 when you test this? If not, how are you determining which User's information is being displayed?
- How is this Content Template applied to your site? Is this part of a View, or the Content Template for a single post type, or archive?
- Where are you testing the results - on a single post page, or an archive page, or a custom page?
- If you disable all plugins except Layouts, Types and Views, is the conditional working as expected?
Hi Christian Cox,
Please check answers to your questions below.
- I can't tell from the screenshots, are you logged in as the User with ID 11 when you test this? If not, how are you determining which User's information is being displayed?
ans : Yes, I am logged in as the User with ID 11.
- How is this Content Template applied to your site? Is this part of a View, or the Content Template for a single post type, or archive?
ans : I have created dashboard template using Toolset > Content Templates then I have created a page "dashboard" and applied that template to page.
- Where are you testing the results - on a single post page, or an archive page, or a custom page?
ans : custom dashboard page
- If you disable all plugins except Layouts, Types and Views, is the conditional working as expected?
ans : I have not installed Layouts plugin.
Thanks
ans : I have not installed Layouts plugin.
Okay my apologies. If you disable everything but Types and Views, is the conditional working as expected?
Types fields typically have the 'wpcf-' prefix in the database, as seen in the screenshot here. How was the _new_user custom field created, and how was data saved into this custom field?
I have added filter for custom field..it is being created when user register in to the site.
function user_register_add_meta($user_id) {
add_user_meta($user_id, '_new_user', '1');
add_user_meta($user_id, 'is_password_changed', '0');
add_user_meta($user_id, 'verification_code',random_password());
}
add_action('user_register', 'user_register_add_meta');
i have created new meta filed..and tried below code but not working
[wpv-conditional if="('[types usermeta='wpcf-is-password-changed'][/types]' eq 'no' )"]
How do you do [types usermeta="wpcf-is-password-changed"][/types] [/wpv-conditional]
Okay I see. Try this:
1. In Types > User Fields, make sure you have a custom field with slug "is-password-changed". If not, create one.
2. Modify your custom code to store information the Types User meta field. Add the wpcf- prefix to the field slug like this:
add_user_meta($user_id, 'wpcf-is-password-changed', 'no');
3. Test by creating a new User. You should see the is-password-changed field in the User's profile set to "no". If you do not see the field in the User's profile, we need to investigate why.
4. Test the value of the field with this shortcode:
Test is password changed: [types usermeta='is-password-changed' output='raw'][/types]
You should see "no" output on your site when logged in as the new user. Specifying output="raw" is important if you plan to use this value in a conditional, because otherwise additional formatting may be applied that will break your conditional logic.
Let me know how it goes.
I have followed steps mentioned by you..I cant see value on my page.
Please check attached screenshot for all 4 steps.
Thanks
Okay and you're logged in as a User who has the ispassword-changed field set to 'no' when you test this, correct? The same code works for me on a local installation, so there must be something else going on. Is it possible to put up a test site somewhere so I can log in and take a look? If so, please send login credentials for a User who the value "no" set for the ispassword-changed field. Then let me know the steps to take so I can view the test message on the front-end of the site. Private reply fields are enabled here.
If that's not possible, I need to see more screenshots showing the rest of the View in your image of step 4.1
Okay I see the problem. You'll need to add the user_current attribute in the usermeta field shortcodes, both in the text output and in the conditional:
Test is password changed: [types usermeta="ispassword-changed" user_current="true"][/types]
[wpv-conditional if="('[types usermeta='ispassword-changed' user_current='true' output='raw'][/types]' eq 'no' )"]
How do you do [types usermeta="ispassword-changed" user_current='true' output='raw'][/types][/wpv-conditional]
I've made that change in the content template for you. Please check and let me know if the conditional is behaving as expected now.
I see the condition you put..but it is not working for me as expected..I would like to display popup window if value of "ispassword-changed" is "no"..I have logged in using user id 62..value for 'wpcf-ispassword-changed' in the database is "yes" so It should not display popup on dashboard..
Can I put wpv conditional is js editor?
Please check attached screenshot for the same.
Thanks
[types usermeta='nickname' user_current='true' output='raw'][/types]
Please check attached screenshot from the database.