phpwordpresspluginsticket-system

Is there a way to add the logged in user profile image to a ticket generated by tickera plugin in wordpress


I have a ticket generated using tickera plugin in WordPress, it contains an image, I want the image in the ticket to be the logged in user's profile image not the image specified with url when adding the element of the image (the drag & drop elements)

I have tried to change the values inside the functions of the file "tcpdf_images.php" with get_avatar() but there were a lot of values to change and each value has a specifications like: ['mime'] or ['extension'] and else, I want to make it in a simple way maybe to edit the tcpdf.php or tcpdf_images.php


Solution

  • My problem was solved by adding user_profile_picture_element.php file inside wp-content/plugins/tickera/includes/ticket-elements/

    user_profile_picture_element.php

    <?php
    if ( ! class_exists( 'tc_user_profile_picture_element' ) ) {
    
    class tc_user_profile_picture_element extends TC_Ticket_Template_Elements {
    
        var $element_name = 'tc_user_profile_picture_element';
        var $element_title = 'User Profile Picture';
        var $font_awesome_icon = '<span class="fa fa-user"></span>';
    
        function on_creation() {
            $this->element_title = apply_filters( 'tc_user_profile_picture_element_title', __( 'User Profile Picture', 'tc' ) );
        }
    
        function admin_content() {
            echo tc_esc_html( parent::get_cell_alignment() );
            echo self::get_dimension_field();
            echo tc_esc_html( parent::get_element_margins() );
        }
    
        function ticket_content( $ticket_instance_id = false, $ticket_type_id = false ) {
            $ticket_instance = new TC_Ticket_Instance( $ticket_instance_id );
            $author_id = $ticket_instance->details->post_author;
            $gravatar_url = get_avatar_url( $author_id );
            $width = isset( $this->template_metas[ $this->element_name . '_width' ] ) ? $this->template_metas[ $this->element_name . '_width' ] : '';
            $height = isset( $this->template_metas[ $this->element_name . '_height' ] ) ? $this->template_metas[ $this->element_name . '_height' ] : '';
            return '<br/>' . apply_filters( 'tc_user_profile_picture_element', '<img src="' . esc_url( $gravatar_url ) . '"' . ( $width ? ' width="' . (int) $width . '"' : '' ) . ( $height ? ' height="' . (int) $height . '"' : '' ) . '/>' );
        }
    
        function get_dimension_field() { ?>
            <label><?php echo esc_html( 'Dimension' ); ?></label>
            <?php _e( 'Width', 'tc' ); ?> <input class="ticket_element_padding" type="text" name="<?php echo esc_attr( $this->element_name ); ?>_width_post_meta" value="<?php echo esc_attr( isset( $this->template_metas[ $this->element_name . '_width' ] ) ? $this->template_metas[ $this->element_name . '_width' ] : '' ); ?>"/>
            <?php _e( 'Height', 'tc' ); ?> <input class="ticket_element_padding" type="text" name="<?php echo esc_attr( $this->element_name ); ?>_height_post_meta" value="<?php echo esc_attr( isset( $this->template_metas[ $this->element_name . '_height' ] ) ? $this->template_metas[ $this->element_name . '_height' ] : '' ); ?>"/>
        <?php }
    }
    
    tc_register_template_element( 'tc_user_profile_picture_element', __( 'User Profile Picture', 'tc' ) );
    }