Change site status setting with front end button

TLDR: Is it possible, on the click of a button on the front end of the website, to update the site status setting?

Context: I have a site with MODX 3.0.2 which the client wants to give as a Christmas present to his new bride. The spec is he wants it to show the Under Construction page until she is able to click a button on some other page “to make the site live”.

Sure.

You’ll have to query the correct modSystemSetting and change it:

<?php
$site_status = $modx->getObject('modSystemSetting', ['key' => 'site_status']);
if ($site_status && !$site_status->get('value')){
    $site_status->set('value', 1);
    $site_status->save();
}

And then it’s probably necessary to clear the cache:

$modx->cacheManager->refresh();

Thank you. Will give that a go now.

WOW!!! Thank you very much Mr. Harry. Works a charm.

Making the tenous and arguable assumption (based purely on your avatar and your perfect use of the American language) that you are also a subject of the prevailing (in the global north west) post-Nazarene hegemony, I’d like to wish you a very Merry Christmas.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.