Home Forums Plugin Support WP User Frontend Pro User Listing & Profile problems

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  towhid 3 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #55489

    Gökhan Aktaş
    Member
    Post count: 50

    Hi, I really in doubt that you are testing your products before release them after i saw these lines in
    …/wordpress/wp-content/plugins/wpuf-user-listing/userlisting.php lines:396-448:

    The args you use in user_comments() function does not even exists in comments table, they are in posts table

    The get_posts() function does not support the argument ‘post_author'

    So, the comments and posts are not shown in profile pages correctly. Page shows all the posts, comments instead of users posts and comments.

    These are just what I found to solve my problem. I fix my problems by editing code, but this is a big issue that must be solved quickly, please release an update so i can use it without any edit.

    
    ...
    ...
    ...
        function user_comments( $user_id, $post_type, $comment_count ) {
    		$args = array(
    			'post_author' 	=> $user_id,
    			'order_by' 	=> 'post_date',
    			'order' 	=> 'DESC',
    			'post_type' 	=> $post_type,
    			'post_status' 	=> 'publish',
    			'number' 	=> $comment_count,
    
    		);
    
    		$comments = get_comments($args);
    
            if ( $comments ) {
    
        		echo '<ul class="wpuf-user-comment">';
        		foreach( $comments as $key=>$comment ) {
        			?>
        			<li>
        				<?php echo wp_trim_words( $comment->comment_content , $this->count_word, '' ); ?>
        				<?php printf( '<a href="%s">%s</a>', get_comment_link($comment), __('...read more', 'wpuf_userlisting') ); ?>
        			</li>
        			<?php
        		}
        		echo '</ul>';
    
            } else {
                _e( 'No comments found', 'wpuf_userlisting' );
            }
        }
    
        function user_post($user_id, $post_type, $post_count) {
    
        	$args = array(
        		'post_author' 		=> $user_id,
        		'post_type' 		=> $post_type,
        		'posts_per_page' 	=> $post_count,
        		'post_status' 		=> 'publish',
        		'orderby'          	=> 'post_date',
        		'order' 		=> 'DESC'
        	);
    
        	$posts = get_posts($args);
        	echo '<ul class="wpuf-post-title">';
        	foreach($posts as $key=>$obj) {
        		?>
        		<li><a href="<?php echo get_permalink( $obj->ID ); ?>"><?php echo $obj->post_title; ?></a></li>
        		<?php
        	}
        	echo '</ul>';
    
        }
    
    ...
    ...
    ...
    
    #55649

    towhid
    Participant
    Post count: 4505

    Hello Gökhan,

    Can I get the fixed code what you have done in the userlisting.php.

    Thanks

    #55674

    Gökhan Aktaş
    Member
    Post count: 50

    I'm not a programmer, but this just worked:

    
    ...
    ...
    ...
        function user_comments( $user_id, $comment_type, $comment_count ) {
    		$args = array(
    			'user_id' 		=> $user_id,
    			'order_by' 		=> 'comment_date',
    			'order' 		=> 'DESC',
    			'comment_type' 		=> $comment_type,
    			'comment_approved' 	=> '1',
    			'number' 		=> $comment_count,
    		);
    
    		$comments = get_comments($args);
    
            if ( $comments ) {
    
        		echo '<ul class="wpuf-user-comment">';
        		foreach( $comments as $key=>$comment ) {
        			?>
        			<li>
        				<?php echo wp_trim_words( $comment->comment_content , $this->count_word, '' ); ?>
        				<?php printf( '<a href="%s">%s</a>', get_comment_link($comment), __('...read more', 'wpuf_userlisting') ); ?>
        			</li>
        			<?php
        		}
        		echo '</ul>';
    
            } else {
                _e( 'No comments found', 'wpuf_userlisting' );
            }
        }
    
        function user_post($user_id, $post_type, $post_count) {
    
        	$args = array(
        		'post_type' 		=> $post_type,
        		'posts_per_page' 	=> $post_count,
        		'post_status' 		=> 'publish',
        		'orderby'          	=> 'post_date',
        		'order' 		=> 'DESC',
        	);
    
        	$posts = get_posts($args);
    
    		foreach($posts as $key => $obj) {
    			foreach ($obj as $valuekey => $value) {
    				if ($valuekey == 'post_author') {
    					if ($value != $user_id ) {
    						unset($posts[$key]);
    					}
    				}
    			}
    		}
    
    		if ( $posts ) {
    			echo '<ul class="wpuf-post-title">';
    			foreach($posts as $key=>$obj) {
    				if ($user_id == $obj->post_author) {
    					?>
    					<li><a href="<?php echo get_permalink( $obj->ID ); ?>"><?php echo $obj->post_title; ?></a></li>
    					<?php
    				}
    			}
    			echo '</ul>';
    
            } else {
                _e( 'No products found', 'wpuf_userlisting' );
            }
    
        }
    ...
    ...
    ...
    
    #55700

    towhid
    Participant
    Post count: 4505

    Hello Gökhan,

    I am very glad to know that you have solved the problem. I will discuss this with our developer team. Hope they will fix this very soon.

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘User Listing & Profile problems’ is closed to new replies.