Hi . how does conditional for cred user form is different from normal field ?
i have this :
[cred_field field="profile-image" force_type="field" class="form-control text-center center-block file-upload" output="bootstrap"]
How do i code to display default image if the profile image is empty ?
I read the documents , and its just get more confusing..
Thanks
seriosuly ? 18 hrs the ticket still no one pickup ??
Hi there,
Thank you for contacting us and we apologize for the delay.
If your goal is to show the default WordPress "Profile Picture" (from Gravatar), when a custom user field "profile-image", is not set, you'll need to a custom shortcode for this.
Here is an example of shortcode that you can add at the bottom of your active child theme's "functions.php" file:
// custom shortcode to check if user image is set
add_shortcode('check_user_image', 'check_user_image_fn');
function check_user_image_fn() {
if (!empty($_GET['user_id'])){
// get the ID of user, whose form is is being edited
$user_id = $_GET['user_id'];
// get the image from user's meta
$profile_image = do_shortcode( '[types usermeta="profile-image" user_id="'.$user_id.'"][/types]' );
if ($profile_image){
// show the custom image if it is set
echo $profile_image;
}
else{
$user_email = get_the_author_meta( 'user_email', $user_id );
$avatar = get_avatar( $user_email, $size = '48', $default = 'mystery');
// show the default Gravatar image if no profile image is set
echo $avatar;
}
}
}
To add this shortcode in your user edit form, you can place it as:
I hope this helps and please let us know if there's anything else we can help you with.
Thanks,
Waqar
Hi. Thanks but I am not using gravatar. User Custom field is" image profile."'
Hi there,
Thanks for writing back and for sharing further details.
The suggested custom shortcode will first check for a custom user field, and if it is empty will show WordPress’ default profile picture (from Gravatar).
If you’d only like to show a default and fixed fallback image when an image is not set for the custom user field (‘profile-image’), you can use the updated code:
// custom shortcode to check if user image is set
add_shortcode('check_user_image', 'check_user_image_fn');
function check_user_image_fn() {
if (!empty($_GET['user_id'])){
// get the ID of user, whose form is is being edited
$user_id = $_GET['user_id'];
// get the image from user's meta
$profile_image = do_shortcode( '[types usermeta="profile-image" user_id="'.$user_id.'"][/types]' );
if ($profile_image){
// show the custom image if it is set
echo $profile_image;
}
else{
// show default fallback image
$fallback_image_URL = "image URL";
echo '<img alt="some alt text" src="'.$fallback_image_URL.'">';
}
}
}
Feel free to replace “image URL” and “some alt text” values as needed.
If we can be of any further assistance, please let us know.
Regards,
Waqar Ali
My issue is resolved now. Thank you!
not related but to highlight that your profile info is different from the rest of the forum supporters .
not related but to highlight that your profile info is different from the rest of the forum supporters .
My issue is resolved now. Thank you!