wpeventmanager / wp-user-profile-avatar

WordPress currently only allows you to use custom avatars that are uploaded through Gravatar. WP User Profile Avatar allow you to change default WordPress avatar or User profile picture. You can use any photos uploaded into your Media Library or use custom photo url as an avatar instead of using Gravatar.
https://wp-eventmanager.com
GNU General Public License v3.0
2 stars 3 forks source link

Need to overwrite template for missing image #110

Closed mistry-jignesh closed 7 months ago

mistry-jignesh commented 8 months ago

Need to overwrite template for missing image .

live-aamir commented 8 months ago

@mistry-jignesh To overrige the template for user avatar on footer. First one needs to put below code in functions.php of parent or child theme. Then, alter the code between the function to get the desired format. Screenshot_14

remove_action( 'the_content', 'wp_author_social_info_box' );

if(function_exists('wp_author_social_info_box')){
    function wp_author_social_info($content) {

        global $post;

       // if (is_single() && isset($post->post_author)) {

    // Get author's display name
            $display_name = esc_attr(get_the_author_meta('first_name', $post->post_author));

    // If display name is not available then use nickname
            if (empty($display_name))
                $display_name = esc_attr(get_the_author_meta('nickname', $post->post_author));

    // Get author's biographical description
            $user_description = wp_kses_post(get_the_author_meta('user_description', $post->post_author));

    // Get author's email
            $user_email = esc_html(get_the_author_meta('email', $post->post_author));

    // Get author's Facebook
            $user_facebook = esc_url(get_the_author_meta('facebook', $post->post_author));

    // Get author's Skype
            $user_skype = esc_url(get_the_author_meta('skype', $post->post_author));

    // Get author's Twitter
            $user_twitter = esc_url(get_the_author_meta('twitter', $post->post_author));

    // Get author's LinkedIn 
            $user_linkedin = esc_url(get_the_author_meta('linkedin', $post->post_author));

    // Get author's Youtube
            $user_youtube = esc_url(get_the_author_meta('youtube', $post->post_author));

    // Get author's Google+
            $user_googleplus = esc_url(get_the_author_meta('googleplus', $post->post_author));

    // Get author's Pinterest
            $user_pinterest = esc_url(get_the_author_meta('pinterest', $post->post_author));

    // Get author's Instagram
            $user_instagram = esc_url(get_the_author_meta('instagram', $post->post_author));

    // Get author's Github
            $user_github = esc_url(get_the_author_meta('github', $post->post_author));

            $user_meta = get_user_meta(get_the_author_meta('ID'));

            $user_link_avatar = get_the_author_meta('_wpupa_url');

            $user_option_id = get_option('wpupa_attachment_id');

            $user_avatar = get_option('wpupa_default');

            if($user_avatar == 'gravatar_default'){
                 $user_avatar = '&';   
            }elseif($user_avatar != 'wp_user_profile_avatar'){
                 $user_avatar = "&d=$user_avatar&";    
            }

            if($user_link_avatar){
                    $user_image = '<img src="'.get_the_author_meta('_wpupa_url') .'" />';
            }elseif($user_meta['_wpupa_attachment_id'][0] != 0){
                    $user_image = wp_get_attachment_image($user_meta['_wpupa_attachment_id'][0],array('90', '90'));    
            }elseif($user_option_id){
                    $user_image = wp_get_attachment_image($user_option_id,array('90', '90'));       
            }elseif($user_avatar == 'wp_user_profile_avatar'){
                    $user_image = '<img src="'.WPUPA_PLUGIN_URL . '/assets/images/wp-user-thumbnail.png" />';
            }else{                
                    $user_image = '<img src="http://2.gravatar.com/avatar/?s=32'. $user_avatar .'r=g&forcedefault=1" />';  
            }

    // Get link to the author  page
            $user_posts = esc_url(get_author_posts_url(get_the_author_meta('ID', $post->post_author)));
            if (!empty($display_name))
                $author_details = '<div class="author-flex">';
            $author_details .= '<div class="author-image">'. $user_image.'</div>';
            $author_details .= '<div class="author-info">';
            $author_details .= '<div class="author-name"><strong>' . get_the_author_meta('display_name') . '</strong></div>';
            $author_details .= '<p class="author-bio">' . get_the_author_meta('description') . '</p>';
            $author_details .= '</div> </div>';
            $author_details .= '<div class="authorbox-social-icons">';

    // Display author Email link
            $author_details .= ' <a href="' . esc_url( 'mailto:' . $user_email ) . '" target="_blank" rel="nofollow" title="E-mail" class="tooltip"><i class="fa fa-envelope-square fa-2x"></i> </a>';

    // Display author Facebook link
            if (!empty($user_facebook)) {
                $author_details .= ' <a href="' . esc_url($user_facebook) . '" target="_blank" rel="nofollow" title="Facebook" class="tooltip"><i class="fa fa-facebook-official fa-2x"></i> </a>';
            } else {

            }

    // Display author Skype link
            if (!empty($user_skype)) {
                $author_details .= ' <a href="' . esc_url($user_skype) . '" target="_blank" rel="nofollow" title="Username paaljoachim Skype" class="tooltip"><i class="fa fa-skype fa-2x"></i> </a>';
            } else {

            }

    // Display author Twitter link
            if (!empty($user_twitter)) {
                $author_details .= ' <a href="' . esc_url($user_twitter) . '" target="_blank" rel="nofollow" title="Twitter" class="tooltip"><i class="fa fa-twitter-square fa-2x"></i> </a>';
            } else {

            }

    // Display author LinkedIn link
            if (!empty($user_linkedin)) {
                $author_details .= ' <a href="' . esc_url($user_linkedin) . '" target="_blank" rel="nofollow" title="LinkedIn" class="tooltip"><i class="fa fa-linkedin-square fa-2x"></i> </a>';
            } else {

            }

    // Display author Youtube link
            if (!empty($user_youtube)) {
                $author_details .= ' <a href="' . esc_url($user_youtube) . '" target="_blank" rel="nofollow" title="Youtube" class="tooltip"><i class="fa fa-youtube-square fa-2x"></i> </a>';
            } else {

            }

    // Display author Google + link
            if (!empty($user_googleplus)) {
                $author_details .= ' <a href="' . esc_url($user_googleplus) . '" target="_blank" rel="nofollow" title="Google+" class="tooltip"><i class="fa fa-google-plus-square fa-2x"></i> </a>';
            } else {

            }

    // Display author Pinterest link
            if (!empty($user_pinterest)) {
                $author_details .= ' <a href="' . esc_url($user_pinterest) . '" target="_blank" rel="nofollow" title="Pinterest" class="tooltip"><i class="fa fa-pinterest-square fa-2x"></i> </a>';
            } else {

            }
    // Display author instagram link
            if (!empty($user_instagram)) {
                $author_details .= ' <a href="' . esc_url($user_instagram ). '" target="_blank" rel="nofollow" title="instagram" class="tooltip"><i class="fa fa-instagram fa-2x"></i> </a>';
            } else {

            }

    // Display author Github link
            if (!empty($user_github)) {
                $author_details .= ' <a href="' . esc_url($user_github ). '" target="_blank" rel="nofollow" title="Github" class="tooltip"><i class="fa fa-github-square fa-2x"></i> </a>';
            } else {

            }

            $author_details .= '</div>';

            $wpupa_hide_post_option = get_option('wpupa_hide_post_option');
            if($wpupa_hide_post_option == ''){
                $content = $content . '<footer class="author-bio-section" >' . wp_kses_post($author_details) . '</footer>';
            }
        //}
        return $content;
    }

    add_action('the_content', 'wp_author_social_info');
}

** This code is in wp-content/plugins/wp-user-profile-avatar/templates/wp-author-box-social-info.php.

mistry-jignesh commented 7 months ago

As per @live-aamir: To override the template for user avatar on footer. First one needs to put the above code in functions.php of parent or child theme. Then, alter the code between the function to get the desired format.

So I closed the issue.