This topic contains 3 reply and 2 voices, and was last updated by towhid 4 years, 1 month ago
Viewing 3 Posts - 1 through 3 (of 3 total)
Author Posts
July 13, 2015 at 7:14 pm 55489
towhid 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>';

    }

...
...
...
July 14, 2015 at 1:26 pm 55649
towhid towhid

Hello Gökhan,

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

Thanks

July 14, 2015 at 3:11 pm 55674
Gökhan Aktaş Gökhan Aktaş

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' );
        }

    }
...
...
...
July 14, 2015 at 4:08 pm 55700
towhid towhid

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 3 Posts - 1 through 3 (of 3 total)