New Listing Status
This topic contains 6 replies, has 2 voices, and was last updated by Stiofan O’Connor 7 years, 2 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: draft, listing default, publish
-
AuthorPosts
-
August 24, 2017 at 5:24 pm #392745
Hello,
I run a geodirectory with multiple CPT that represent various categories. The directory is free for all, but I have two (similar) issues I could use help with. For most people I want the listings to goto draft form (which it does), however for certain organizations I would like them to have the ability to direct publish.Additionally on one directory I would like everyone to have the ability to publish immediately. I use the directory for a non-standard type use and hence have some unique challenges.
Any information or suggestions would be a great help!
ThanksAugust 24, 2017 at 5:47 pm #392750Hi Shane,
Are these paid or free listings or mixed?
I don’t think there is a way to alter this per CPT, but is that what you are asking or are you asking per user?Please explain a bit more and i’ll be able to suggest the best action.
Thanks,
Stiofan
August 24, 2017 at 5:53 pm #392752Sure… so to clarify both point.
First all are freeIn one case I use it as a weather alert map..and I want everyone to be able to post automatically to that CPT without draft
On the other I use it as a crime directory I want to allow police agencies the ability to post directly, but the normal people to goto draft.
For the police issue I considered creating a package and only allowing aurthoized agencies the ability to sign up for it..to overcome that..I haven’t gotten that far.
My current big challenge is how to make a single CPT have a default listing as published while the others remain draft…due to the time critical nature of weather emergenciesAugust 24, 2017 at 6:45 pm #392757Ok i think this is what i would do…
Set the default status to “Pending Review” and then add a hook on post_save that checks the conditions and sets the status publish only if met, example below (NOT TESTED):function _my_save_post_actions($post_id, $post, $update) { // if an update then bail. if($update){ return;} // a post type check if ( isset($post->post_type) && $post->post_type=='gd_place' && $post->post_status!='publish') { // unhook this function so it doesn't loop infinitely remove_action( 'save_post', '_my_save_post_actions', 10 ); // we want to publish all gd_place listings wp_update_post(array( 'ID' => $post_id, 'post_status' => 'publish' )); // re-hook this function add_action( 'save_post', '_my_save_post_actions',10, 3 ); } // a user check $current_user_id = get_current_user_id(); $allowed_user_ids = array(1,5,10,20);// list of allowed user ids if ( in_array( $current_user_id, $allowed_user_ids) && $post->post_status!='publish') { // unhook this function so it doesn't loop infinitely remove_action( 'save_post', '_my_save_post_actions', 10 ); // we want to publish all gd_place listings wp_update_post(array( 'ID' => $post_id, 'post_status' => 'publish' )); // re-hook this function add_action( 'save_post', '_my_save_post_actions',10, 3 ); } } add_action( 'save_post', '_my_save_post_actions',10,3 );
hopefully that example is enough to get you going 🙂
Thanks,
Stiofan
August 24, 2017 at 7:35 pm #392764Stiofan, and WPGEO in general as always thank you for the excellent customer service!
I’m not very familiar with the process of hooks, but will read up and I’m sure I can figure it out. For my clarity should this accomplish both points I was asking about or only one?August 24, 2017 at 9:06 pm #392776Just out of curiosity. .. do y’all do customization (like the above?) If so how would I go about getting a quote for it?
August 25, 2017 at 10:50 am #392841Hi Shane,
We do not do customization, we will provide you examples of how our hooks/filters work but we won’t build your site for you. You can post in the forum jobs section or try hiring a developer elsewhere.
The above example would do both things but you would need to replace the custom post type name and the user IDs with your specific requirements.
Thanks,
Stiofan
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket