Skip Navigation

[Gelöst] Expiration for posts

This support ticket is created vor 6 Jahren, 4 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 9 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Ljuba vor 6 Jahren, 4 Monaten.

Assistiert von: Nigel.

Author
Artikel
#951461

==> Tell us what you are trying to do?

I have 'Deals' CPT. Post should to appear in two cases:

1) On user business page.

2) Site wide (as Ad's - so, this case is covered by docs/tutorial below).

USER PAGE

By paid membership, user paid right for 'Deals' space on his own page without expiration. However, user certainly want to have control over expiration of the deals by himself (seasonal discounts, coupons time limit, etc.). But he also want to be able to decide did he want to permanently delete offer or to keep it for later renewal.

in other words, in this case, user should to be able to set expiration date by himself (from his Dashboard), as well status of post (deleted/published/hidden - from front page, not from user dashboard page).

I don't need detailed explanation, as I yet didn't set it. I need to know - is it possible to be done (and how? - but roughly explained)?

ADDITIONAL QUESTION

Site wide publicity case.

How should to be organized that above same Deal post user can time per time to enable on site wide pages (ie Hotel Archives Header) per limited time. Obviously he need to have sort of Dashboard CRED form where he choose the page, position on the page (View) and time (ie - week) what should to result with outcome of (ie) 'Week Premium Pack' and price of (ie) 5$ what after payment should to publish the Ad.

If that is correct, I don't need more help now in topic. If not, please explain how it should to work.

==> Is there any documentation that you are following?

https://toolset.com/documentation/user-guides/cred-training-course/part-4-setting-automatic-expiration-posts/

#952321

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Ljuba

If you are using Toolset Forms (CRED) then posts that are submitted or edited via a form with post expiration activated will set a fixed post expiration, based upon the settings of the form.

So if you have a form with the setting "posts expire 3 months from now" then that will be applied to all submitted posts.

Once such posts are submitted, if you edit the posts in the backend you will see when the post is due to expire, and you can update it from the post edit screen when you save the post.

The expiry date is stored as a UNIX timestamp in wp_postmeta for the post, with the key "_cred_post_expiration_time".

So you can customise this using the cred_save_data hook (https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data).

You could conceivably have a select field in the form to choose how long the offer should last before expiring, and then when the form is submitted you run a little code with the cred_save_data hook which updates the _cred_post_expiration_time post meta according to what was chosen in the form.

Note that the status of the post when it expires is a form-wide option that will be applied to all posts created with the form.

If you also want the user to be able to customise this per post then you would need to update the _cred_post_expiration_action post meta as well.

This stores the status that will be applied upon expiration inside an array, something like this:

Array
(
    [post_status] => draft
    [custom_actions] => Array
        (
        )
)

Note this is not documented, you'll be tinkering with how expirations work.

I didn't quite follow your additional question. Maybe it is clearer based upon the above.

#952439

==> Thanks. You fully answered all what I for now need to know related to main question, including 'draft' part.

==> On my main domain site, you can in Demo Negocio see what I mean by second question. There are Deals on Customer Business page and he himself manage (as you explained above) those Ads, as he have right to have it for lifetime. So, he will just get in Dasboard field to Enable/Disable it (what you explained above). Basically, they are not 'normal classic Ads', rather kind of the post content (done trough child posts - same like - ie - Rooms or Schedule). Only difference is that user should to be able to Enable/Disable that content front display per his own wish (so, 'drafts'/'published').

So, my second question was - how to get that Customer can that SAME DEALS FROM USER PERSONAL PAGE to publish per expiration (plan) ground on other pages of the site (archives, free posts, ....). I know that I will need to create View for this and to conditionally input something to be able to control it. Question is - can it be done or not?

More simple option is to simply force Customer to create 'normal Ads' (so, to upload content from same Deal again) for every single case (when he want and for how long he want and wherever he want to display). Downside is content duplication.

Basically, essence of question is - can I use same existing User Page Deals to achieve that goal or it is 'much more smart' to separate it?

My idea is to get Content Templates per single post Deal (View done by that Content Template for USER SINGLE PAGE - see Demo Negocio) and also to be able to make some other View(s) where I can display THAT SAME POST (Deal) as Ad on custom (by user) chosen pages with expiration date.

Think what I don't know (as I never used Classifieds feature and Luo completely confused me) is - can I same Post (Deal) in one case to use as 'ordinary' content (on user single page - solved in your reply) and in second case with expiration (as expiration is per post and not per View, right?)? Regards your remarks about timestamp, for me looks that I need another Post Type, but .....

P.S. It looks that Toolset don't update another ticket replies https://toolset.com/forums/topic/expiration-for-posts/#post-952439

#953704

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Ljuba

Sorry, I'm losing track of where we are up to in terms of which demo sites I should be looking at, could you please remind me which is the current site you mentioned I should check in your last reply?

As a general observation regarding the comment in your last paragraph, post expiration is set for each post individually (with the actual expiration datetime stored as post meta), there is no post expiration setting for a View.

If I am understanding you correctly, you need a View that is for the USER which lists HIS deals from which he can via a Form set them as active or inactive (published or draft) and, if active, for how long (post expiration date for that deal). You would need some code to run when the form is submitted to manually override the post expiration which is global for that form.

Then when it comes to displaying these deals in other locations you would just go ahead and try to display them using a View, but the View won't include draft posts in the results, so will only include active deals (and you can output nothing in place of the normal "no results found").

If that sounds right I can move on to look again at the opening hours problem.

#954282
001.jpg

OK, one by one:

1) OLD LINK Data for old 'untouched' (from your last work) Opening Hours are visible at https://toolset.com/forums/topic/opening-hours/#post-774283

P.S. Nothing is touched from your work.

2) NEW LINK Data for actual working site are visible at https://toolset.com/forums/topic/taxonomy-view-with-a-taxonomy-view/#post-923634 (main post front view is Alojamientos demo post, you'll see)

P.S. Vs. 'opening hours', just to note that I mainly just imported old Types module and slightly changed it (extended), for purpose to be able to use same post type for many schedule and/or timetable types. Accordingly, only couple of slugs are changed (at root of the post types structure - so, your View and codes snippets are not completely applicable). However, I repeat (you can see), Abierto/Cerado (code snippet) not working also in old (original) site.

3) Regards the 'Deals' maybe is best to go step by step (you will understand than easy). So, I suggest that first you just help me to finish 'Deals' 'View' on user business single page and than you will get what I ask.

'DEALS' EXPLANATION

'Ofertas' are (very simple) child post of Negocios, Alojamientos, Gastronomia, Servicios and Compras. On attached image, you can see user business (her - Alojamiento single post page) in header left 1/3 column of Galery, how I set View Slider for 'Featured Deals'. Second section is easy visible bottom (see menu link). It should to be placed in 'Accordions' as 3 columns View (see above Accordions). Here I have also small problem (below explained).

Briefly, user can create his 'deals' (as photo or HTML) and place it in "unlimited" numbers (not really) on his own section of Deals on his own business page. By checking 'featured deal' he also can place his own selection of those deals in header slider (and it works just fine). From his Dashboard, he will be able to check/uncheck 'featured deals' in any time (depends when and what he want to promote.

On same principle of 'featured deals' checkbox, I will set 'enable/disable deals' on his page (so, remain visible on his Dashboard, but not actively visible on his business page, front pages - generally). Example, he logically don't want to make visible summer deals in winter to not 'crowd' the page.

'DEALS' VIEW PROBLEM

As I want on user business page to place 'Deals' within Accordions 3 columns rows, I created Template for View of Single Deal (to display it in 3 columns - that you can see on page now). Than I created another Template (where I should to build Accordions to place conditionally those Views by Taxonomy (Tipos de ofertas) and it looks like (jus tpart of row/simple version)

[wpv-conditional if="( '[wpv-post-taxonomy type='tipo-de-oferta' format='slug']' eq 'asociacion-de-producto' )"]
<h3>Asociación de producto</h3>
[wpv-view name="view-para-ofertas-single"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-taxonomy type='tipo-de-oferta' format='slug']' eq 'concursos-de-venta' )"]
<h3>Concursos de venta</h3>
[wpv-view name="view-para-ofertas-single"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-taxonomy type='tipo-de-oferta' format='slug']' eq 'descuentos' )"]
<h3>Descuentos</h3>
[wpv-view name="view-para-ofertas-single"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-taxonomy type='tipo-de-oferta' format='slug']' eq 'eventos' )"]
<h3>Eventos</h3>
[wpv-view name="view-para-ofertas-single"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-taxonomy type='tipo-de-oferta' format='slug']' eq 'ofertas-de-cupones' )"]
<h3>Ofertas de cupones</h3>
[wpv-view name="view-para-ofertas-single"]
[/wpv-conditional]

Problem is that don't show anything. What is the issue?

'DEALS' FURTHER

Please, first to set this, to be able to easy explain what I want for Archives pages from same 'Deals'.

P.S. On image you can also see what is the problem with another topic and 'collapse' (see payments and booking rows are opened at same time - instead to 'switch').

#954293

In meantime, I also added View and your snippets to Horario (you will see Abierto/Cerrado in Header and Horario under Politicas.

Neue Threads, die von Nigel erstellt wurden und mit diesem verbunden sind, sind unten aufgeführt:

https://toolset.com/de/forums/topic/split-displaying-terms-in-accordion-style-list-with-embedded-view/

#956514
003.png
002.png
001.jpg

OK Before we go to solve the topic, something not working for me.

1) Image 001 shows (2 red rectangles) how my post view of taxonomies is just fine, as well taxonomy view of that nested post view. I have 3 deals in 2 categories and it is displayed correctly. Code is visible on image 002.

2) Following documentation and topic https://toolset.com/forums/topic/basic-accordion-implementation-in-views-without-shortcode/#post-588751, when I 'wrap' previous code in accordions, view shows me only first view (Descuentos) and second accordion is not possible to open (Promociones).

	<wpv-loop>
  		<a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapse-[wpv-post-id]" aria-expanded="false" aria-controls="collapse-[wpv-post-id]">
  			[wpv-taxonomy-title]
		</a>
 
  		<div class="collapse" id="collapse-[wpv-post-id]">
    		<div class="well">
      			[wpv-view name="view-para-ofertas-single"]
    		</div>
  		</div>
	</wpv-loop>

What I do wrong?

#956533

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

I've been reading through the above and following on your site, and it seems like the issue we are left with is how to display a list of terms with nested Views in an accordion structure.

I've split that into a separate thread and I'll answer there, as it seems like we have moved on from the original question.

#956551

Yes, I noticed and thanks.

Now you can see idea (hopefully), more clear. On user single page he will have 2 sections to display his 'Deals' and they are not subject of payments and/or expiration. With checkbox, he will be also able to Enable/Disable visibility of 'Deal' on his own page (plus, 'normal' function to be able to delete post/'Deal', completely).

So, goal is to simplify usage of the site by users. To not force them to make many times same 'Deals' (Ads). Basically, my question (topic) 'handle' with options within existing post type - here, 'Deals'. In meantime, I thought how that was wrong, concept and I think that figured (theoretically) how to do it very efficiently.

'New idea' is to let user to go as it is with 'Deals' and to create new parent post type - ''Ads'. Ads should to 'pull' the promotional content from existing 'Deals' and to have options of expiration and possibility to choose what 'View advertising place' (header, footer, sidebars, ...) will be chosen on what (archive) page(s) of the website. In fact, should to be sort of 'easy' task to do.

Actually, issue is solved and I will close the ticket.

#956552

Thanks.