Limit listing posts with Directory plugin

Hi,

I'm using the Directory plugin and I want to know how to limit the member to post only one listing.

I think by default is unlimited.

Thank You.

  • Ash

    Hello @Jose

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    Limiting listing is not possible out of the box. Would you please try this plugin?
    https://wordpress.org/plugins/bainternet-posts-creation-limits/

    It claims that it can limit on custom post type too. For listing, the custom post type is directory_listing.

    Please give it a try and let us know if it works for you.

    Cheers
    Ash

  • Ash

    Hello @Jose

    I hope you are well today.

    In that case, you have to customize the plugin.

    Please go to /plugins/directory/core/main.php line no 86 to 91:

    $draft = $_POST['listing_data']['post_status'] == 'draft';
    				$post_id = $this->update_listing( $_POST );
    				$meta = new DR_Meta($post_id);
    
    				// The credits required to renew the directory for the selected period
    				$credits_required = ($this->use_free) ? 0 : $options['credits_per_listing'];

    replace with

    $draft = $_POST['listing_data']['post_status'] == 'draft';
    
    				$user_post_count = count_user_posts( get_current_user_id(), 'directory_listing' );
    				if( $user_post_count > 0 ){echo 200;
    					wp_redirect( add_query_arg( array( 'updated' => 'false', 'dmsg' => urlencode( __( "You don't have enough permission.", $this->text_domain ) ) ), get_permalink($this->my_listings_page_id) ) );
    					exit;
    				}
    				else{
    
    					$post_id = $this->update_listing( $_POST );
    					$meta = new DR_Meta($post_id);
    
    					// The credits required to renew the directory for the selected period
    					$credits_required = ($this->use_free) ? 0 : $options['credits_per_listing'];
    				}

    Please note that, this changes will be lost in next update. So it's worth to note down this changes somewhere and apply again after your updates.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.