Skip Navigation

[Resolved] Ref : Conditional output with custom image field in cred edit form

This thread is resolved. Here is a description of the problem and solution.

Problem:

In a CRED form for editing user, the client is going to display it when user's image is blank and not blank:
[cred_field field='profile-picture' value='' urlparam='' output='bootstrap']

Solution:

You just need t display it directly, see the solution here
https://toolset.com/forums/topic/ref-conditional-output-with-custom-image-field-in-cred-edit-form/#post-900401

Relevant Documentation:

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 2 voices.

Last updated by vimalS 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#897118
Screenshot_1.png

To be continued : https://toolset.com/forums/topic/conditional-output-with-custom-image-field-in-cred-edit-form/
My code looks like this

[wpv-conditional if="( '[types usermeta='profile-picture' output='raw' user_is_author='true'][/types]' ne '' )"]
        [cred_field field='profile-picture' value='' urlparam='' output='bootstrap']
        [/wpv-conditional]
        [wpv-conditional if="( '[types usermeta='profile-picture' output='raw' user_is_author='true'][/types]' eq '' )"]
        <div class="no-profile-image">
          [wpv-initials id='[wpv-get-user-id]']
        </div>
        [/wpv-conditional]

When I put above code it shows image with initials when user image is blank...but, it is not displaying browse button to upload new image and not showing actual uploaded image

#900239

Hello,

I suggest you debug your codes, line by line, for example:
Output the user image field directly:
[types usermeta='profile-picture' output='raw' user_is_author='true'][/types]

Make sure it does output correct value.

As you can see, it is outputting author data of current post, if you need to output data of current logged in user, please try this:
[types usermeta='profile-picture' output='raw' user_current='true'][/types]

#900287
Screenshot_1.png
Screenshot_2.png

Yes, I have changed code as per current user.

[wpv-conditional if="( '[types usermeta='profile-picture' output='raw' user_current='true'][/types]' ne '' )"]
		[cred_field field='profile-picture' value='' urlparam='' output='bootstrap']
        [/wpv-conditional]
        [wpv-conditional if="( '[types usermeta='profile-picture' output='raw' user_current='true'][/types]' eq '' )"]
        <div class="no-profile-image">
          [wpv-initials id='[wpv-get-user-id]']
        </div>
        [/wpv-conditional]

So, now it will show user's image if it is not blank and show initials if image is blank.
When Image is blank it shows initials but not showing "change your picture". "change your picture" will allow user to upload new Image.
Can you give me solution?

#900401

I assume we are talking about a CRED form for editing user, and the shortcode you mentioned above:
[cred_field field='profile-picture' value='' urlparam='' output='bootstrap']

And you are going to display it when user's image is blank and not blank. if it is, you can put it outsider the [wpv-conditional] shortcode, for example:

        [cred_field field='profile-picture' value='' urlparam='' output='bootstrap']

        [wpv-conditional if="( '[types usermeta='profile-picture' output='raw' user_current='true'][/types]' eq '' )"]
        <div class="no-profile-image">
          [wpv-initials id='[wpv-get-user-id]']
        </div>
        [/wpv-conditional]
#900693

Yes, Correct

#900809

Does the solution work for you?
https://toolset.com/forums/topic/ref-conditional-output-with-custom-image-field-in-cred-edit-form/#post-900401

Please let me know if you still need more assistance.

#900845
Screenshot_3.png

No, Its not working. see attached screenshot.

#900853

So it is another problem, the shortcode does not work in your website.
[cred_field field='profile-picture' ...]
It is not related with [wpv-conditional] shortcode.

I suggest you setup the CRED again, with the "Auto-Generate User Form" button, make sure above shortcodes can output a image field in your CRED form.

And the problem you mentioned above is abnormal, in case it is a compatibility problem, please try this:
1) deactivate other plugins and switch to wordpress default theme, and test again
2) If the problem still persists, please provide a database dump file (ZIP file) of your website in below private detail box, also point out the problem page URL, I need to test and debug it in my localhost, thanks

#900898

Hi Luo,

My file size is big. not able to upload.

Thanks

#901224

You can put the file in your own google drive disk, and share the links in the private detail box

#901855

Thanks for the details, I am downloading the files, will feedback if there is anything found

#901861
ts.JPG

Here is what I found:
It is a problem of your custom theme, you can switch to wordpress default theme or original parent Toolset starter theme, and test again, see screenshot ts.JPG

After switch to original parent Toolset starter theme, I can see the file field "Profile picture" without any problem, can you confirm it?

I have tried to locate the problem in your custom theme files, it seems to be a CSS problem, you can try to remove your custom CSS codes in file toolset-starter-child\style.css, and test again.

#902472

Yes, its working