Home › Forums › General Issues › Front end field checkbox with: Mark as Read
I have to create a field in front end for each subscriber that can mark the post as read.
So the following basic code, with a checkbox field:
<?php
$args = array(
field_groups' => array( 1152 ),
);
acf_form( $args );
?>
In functions:
function my_acf_save_post($post_id) {
wp_update_post();
add_action('acf/save_post', 'my_acf_save_post', 20);
}
Now i can update the field in front end post, but how can I associate this field for each subscriber so that each account can mark the post?
Some more information
I want to set a flag, so a user will know which post he has read and which he has not read.
Perhaps the best solution for me is to associate this flag for each user id and store everything in the post object. Is it possibile?
What you’re asking for is more complicated than creating a form or a simple script.
You would need to have a field of some kind that saves values specific for each user. This field would need to be able to store multiple values so that every post they mark as read would be recorded…. a relationshipt field
The alternative is to have a field on every post that stores multiple values to record every user that has marked it as read… a user field
Then you would need to create an AJAX script that updates this field, whichever way you decide to go, when the user checks or unchecks this box.
When showing this field you’d need to see if it should be checked or unchecked by comparing the post ID with the field you decide to use for this.
What do you think about it?
$args = array(
'post_id' => 'user_'.$current_user->ID,
'field_groups' => array( 1152 ),
//'fields' => array('test_semplice_'. $author_id2 ,'gruppo_test_'. $author_id2, 'field_5e93382ad5331', 'field_5e933c0c66134'),
'updated_message' => 'Stato attività aggiornato',
);
acf_form( $args );
I just google and came up your post. Interesting..and thanks for sharing
The topic ‘Front end field checkbox with: Mark as Read’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.