Home Forums Front-end Issues All users can edit frontend post


All users can edit frontend post

  • Hi,
    I have a page called post-edit.php where i pass post ID by querystring foe example (
    At this page there is ACF_form where i allow the current post to e edited. All is fine, except all users can edit all posts, but i want them to edit only the post they created, not on others.
    Here is my code on page post-edit.php

    <?php <strong>$post_id = $_GET["post"];</strong> ?>
    <?php acf_form_head(); ?>
    <?php get_header(); ?>
    	<div id="primary" class="content-area">
    		<div id="content" class="site-content" role="main">
    		<h2>Edit your Listing</h2>
    			<?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php acf_form(array(
    					'post_id'	=> <strong>$post_id</strong>,
    					'post_title'	=> true,
    					'submit_value'	=> 'Update Opportunity'
    				)); ?>
    			<?php endwhile; ?>

    So what i want is, to check if the current user is author of the post, and if he is the author, to show the post for editing, otherwise redirect or not show the post.

Viewing 1 post (of 1 total)

The topic ‘All users can edit frontend post’ is closed to new replies.