Skip Navigation

[Résolu] Ref : Conditional output with custom image field in cred edit form

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 6 années et 6 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 12 réponses, a 2 voix.

Dernière mise à jour par vimalS Il y a 6 années et 6 mois.

Assisté par: Luo Yang.

Auteur
Publications
#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