marginaali
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Hacks
In reply to: Custom post types draw an error on post-template.php on line 298Problem found, it was because of a query on a single.php file which helped to create a post loop on the page from the custom posts. It didn’t break up before I created the said post types and used them in the loop.
Forum: Hacks
In reply to: Can users add things to posts/pages without going to edit mode?Thanks latro!
I had a bit of a fight with the Advanced custom fields but you helped a lot!
I ended up using code which looks something like:
<?php if( is_user_logged_in()): ?> <?php global $current_user; get_currentuserinfo(); $current = get_field( "the-field" ); $user = $current_user->user_login; //See that the user is already marked themselves present if (strpos($current, $user) !== false): echo nl2br ("You are already taking part"); else: ?> <form method="post"> <input type="submit" name="marker" value="Add yourself" /> <input type="hidden" name="aid" value="<?php echo($post->ID) ?>" /> <input type="hidden" name="person" value="<?php echo($current_user->user_login) ?>" /> </form> <?php endif; ?> <?php endif; ?> <h2> Participants: </h2> <?php if ( isset( $_POST['marker'] )): $current = get_field( "the-field" ); $user = $_POST['person']; if (strpos($current, $user) !== false): echo nl2br (""); else: $current = get_field( "the-field ); $user = $_POST['person']; $updated = $current . $user . "<br/>"; update_field('the-field', $updated); ?> <?php endif; ?> <?php endif; ?> <p>Participants: <?php the_field('the-field'); ?></p>
Viewing 2 replies - 1 through 2 (of 2 total)