I am using ACF(advance custom field) and custom post type plugin to create my own custom post type.
I have successfully created custom post type with custom field. [no problem here]
Then i have display all custom posts to users(front end user) after login. [no problem here].
if front end user(after login) like particular custom post, he/she will fill-up free subscription form against particular custom post and submit it.
Now i want to display all custom posts to users but if user already subscribed for particular post then i want to show it with different color. any solution for this?
When user submits the subscription form, save the current post id in users meta data using some custom meta key(subscribed_posts)
<?php
add_user_meta( $user_id, 'subscribed_posts', $post_id);
//$post_id is the id of post user subscribes to.
?>
Now while displaying the post in frontend, just check for the post id and use some specific class to display in different color(write css for that class in your style.css, i've used the class green for subscribed and grey for not subscribed posts.)
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'post_status' => 'publish',
'fields' =>'ids'
);
$the_query = new WP_Query( $args );//Query for all post that you want to display
if ( $the_query->have_posts() ) :
$subscribed_posts = get_user_meta($user_id);//Get current user id and fetch all subscribed posts.
while ( $the_query->have_posts() ) : $the_query->the_post();?>
<div class="default <?php echo in_array(get_the_ID(),$subscribed_posts)?'green':'gray'?>">
/*Your post content for every post goes here*/
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
Would have been more specific if you had showed the specific codes and html