Title: Privite post
Last modified: November 12, 2019

---

# Privite post

 *  Resolved [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/)
 * (@kpmediadesigner)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/privite-post/)
 * I have one more thing that would be great to have some help with.
    So I need 
   to accomplish the following: When someone makes an advert they need to be able
   to manage and change it, BUT in the meantime, it needs to be forced into being
   inaccessible to other users (even with a direct URL link to the post). The reason
   is what posts you see is limited to an area within 25 miles ( I already added
   my custom plugin and shortcode that does this and works great with it ), but 
   right now you can still access adverts outside of that area if you have the direct
   URL. I figure this should be pretty easy to fix. I’m happy to do it in my plugin
   PHP code too. Whatever works is fine with me 🙂
 * Oh, and I already tried moderate=”1″, but that prevents the user from editing
   their post if they want from what I can tell.
 * Thank you!
    This project is coming along, hopefully only another few weeks before
   we go live.
    -  This topic was modified 6 years, 7 months ago by [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/).

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/privite-post/#post-12121105)
 * Hi,
    sorry, but i am not exactly sure what you would like to do?
 * The users can edit the inactive Ads from a page with [adverts_manage] shortcode.
   If you would like to disallow access to some Adverts you can do that for example
   in the template_redirect action
 *     ```
       add_action( "template_redirect", function() {
         $user_can_see_advert = true;
         if( is_singular( 'advert' ) && ! $user_can_see_advert ) {
           wp_redirect( "https://link/to/some/other/page" );
           exit;
         }
       } );
       ```
   
 * You just need to change the line `$user_can_see_advert = true;` to code which
   will check if the user can see the Advert and the “[https://link/to/some/other/page&#8221](https://link/to/some/other/page&#8221);
   link to a link to which you will redirect users without valid access.
 *  Thread Starter [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/)
 * (@kpmediadesigner)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/privite-post/#post-12123864)
 * Ok thank you for that bit of code. However, the user cannot still make edits.
   I go to the manage ads page and it displayed this message:
    “You do not have 
   any Ads posted yet.”
 * But if I change the ad I just posted on from “Status: Pending Review” to ” Status:
   Published” it does appear on the same page upon refresh. If I can allow the user
   to make edits still with it pending review that’s basically what I’m looking 
   for.
 *  Thread Starter [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/)
 * (@kpmediadesigner)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12125214)
 * Let me try and make it super clear:
    -I want to allow the advert poster ( lets
   call him Bill ) to make a post. -The post is only visible to Bill even if he 
   wants to share it. -Bill can go back and edit the post to fill in a field that
   asks for another users username ( Lets call the user Joe ). -When Bill enters
   Joe’s username It makes Joe the new author of the advert post, so Joe can make
   changes. ( I’m doing this in a custom validator ). – Joe can then mark the post
   to be publically visible. ( I can do this part myself, so actually getting it
   marked for being public isn’t a big deal, but if you have a nice clean way to
   do it I’m all ears ).
 * I know it seems weird, but when it’s done it will totally make sense. I was wondering
   if its possible to only show the field requesting a username after you have already
   published the post and gone back to make an edit (Joe’s username in this case).
 * Basically Paid users need to take over for free users (Joe is a paid user and
   Bill is free) before the post is public. Thats the goal anyways.
    -  This reply was modified 6 years, 6 months ago by [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/).
    -  This reply was modified 6 years, 6 months ago by [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/).
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12125810)
 * Hi,
    ohh ok, so if i understand correctly the main problem is that the Ad is 
   not visible in the [adverts_manage] even though it is assigned to the user?
 * If so then you can add the “Pending Review” status to the list of statuses visible
   in [adverts_manage] by adding the code below in your theme functions.php file
 *     ```
       add_filter( "adverts_sh_manage_list_statuses", function( $list ) {
         $list[] = "pending";
         return $list;
       } );
       ```
   
 * It is possible to conditionally display a username field although it is not exactly
   clear for me when it should show, from the description i understand that only
   Bill should see it and once he will assign the Ad to Joe the user name field 
   is no longer needed?
 * Also how should the WPAdverts know if the user is paid or free user?
 *  Thread Starter [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/)
 * (@kpmediadesigner)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12130147)
 * That code snipped is perfect. Yup, that was what I needed there.
 * So I want the username field to only show after the post has actually been created.
   If they are adding it for the 1st time and it isn’t already saved in the database
   I don’t want to display it (as its meant to hand over authorship to Joe, and 
   it doesn’t make sense to hand over authorship to a post before the post actually
   exists I’m thinking).
 * WHen BIll makes the post I have a shortcode that will send Joe a notification
   that someone in his area made the post. Joe will then contact bill through the
   info I provide in the notification and tell Bill to enter his username and give
   him authorship. Having the field there before this point may confuse new users,
   so I want to hide it.
    -  This reply was modified 6 years, 6 months ago by [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/).
 *  Thread Starter [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/)
 * (@kpmediadesigner)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12130150)
 * Oh and to answer your question on paid users, I’m using the profile builder plugin
   that has a paid memberships addon, and then just pulling the metadata with $wpdb
   to find the subscription of the user from an ID.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12130778)
 * Hi,
    ok, so basically the Username field should be only in the [adverts_manage]
   field as only there the users can edit the Advert after posting it.
 * If so then you can add the field only when editing by using the code below
 *     ```
       add_filter( "shortcode_atts_adverts_manage", function( $args ) {
         add_filter( "adverts_form_load", "custom_username_field" );
         return $args;
       } );
       function custom_username_field( $form ) {
         if( $form['name'] != "advert" ) {
           return $form;
         }
         $form["field"][] = array(
           "name" => "adverts_custom_username",
           "type" => "adverts_field_text",
           "order" => 12,
           "label" => __( "Username", "adverts" ),
         );
         return $form;
       }
       ```
   
 *  Thread Starter [kpmediadesigner](https://wordpress.org/support/users/kpmediadesigner/)
 * (@kpmediadesigner)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12135239)
 * You are the best! Thank you.
    Just for the future, is there somewhere in the 
   documentation that I could have figured that out from? I want to try and figure
   this stuff out myself so I don’t keep bothering you with it. Either way top-notch
   support.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12135941)
 * How to customize the forms is explained here
    [https://wpadverts.com/documentation/forms-api/](https://wpadverts.com/documentation/forms-api/)
   [https://wpadverts.com/documentation/custom-fields/](https://wpadverts.com/documentation/custom-fields/)
 * The `shortcode_atts_{$shortcode_name}` is a standard WP filter executed on all
   shortcodes params which just happened to be useful in this case :).

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Privite post’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/privite-post/#post-12135941)
 * Status: resolved