WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms - Update Post
Restricting Update Post to Post Author (3 posts)

  1. ktrusak
    Member
    Posted 1 year ago #

    In the readme it says there is a way to restrict the editing of a post to the author through filters.

    Do you have an example of the filter for this?

    http://wordpress.org/extend/plugins/gravity-forms-update-post/

  2. riccardo.raneri
    Member
    Posted 1 year ago #

    Hi, this post is quite old but it still needs an answer.

    I figured out how to change this settings, for example:

    add_filter('gform_update_post_options', 'gform_update_post_options');
    
    	public function gform_update_post_options($options)
    	{
    	  $options['capabilities'] =  array(
    	      'update' => 'author',
    	      'delete' => 'author'
          );
    	  return $options;
    	}

    With this (you can put it in your theme's functions.php), authors can edit (and delete) their posts.

  3. ktrusak
    Member
    Posted 1 year ago #

    Hey, thanks for the follow up. That is probably the best route. I couldn't figure out the options so I wrote a work around. I'll post it so if anyone wants it:

    function gf_update_author_check(){
    
    	if (isset($_GET["gform_post_id"])){ 
    
    		$id = $_GET["gform_post_id"];
    		$post = get_post( $id );
    		$user = wp_get_current_user();
    
    			if($user->ID != $post->post_author){ 
    
    					wp_redirect(home_url());
    					exit;
    
    		}  
    
    	} 
    
    }
    add_action('template_redirect', 'gf_update_author_check', 1);

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.