Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm a bit new to wordpress and php and I'm trying to create a site where users have the possibility to change the appearance of the index page for other visitors. This could perhaps be done with back-end access to a maintenance plugin but I want it to be more simple than that for the user. Basically just log in and then push a button to open the site.

What would be the best way to achieve this?


[Update]

# Plugin name 'Name' => 'Maintenance Mode',
# Author of the plugin 'Author' => 'Michael Wöhrer',
# Authot URI 'AuthorURI' => 'http://sw-guide.de/',
# Plugin URI 'PluginURI' => 'http://sw-guide.de/wordpress/plugins/maintenance-mode/',
# Support URI: E.g. WP or plugin forum, wordpress.org tags, etc. 'SupportURI' => 'http://wordpress.org/tags/maintenance-mode',
# Name of the options for the options database table 'OptionName' => 'plugin_maintenance-mode',

share|improve this question
    
What do you mean by "open the site"? That any user can disable/enable the maintenance mode?¿ –  brasofilo Jun 25 '12 at 20:12
    
Exactly! In a very simple manner. Log in and then push a enable site button in the front-end. –  Pxl Jun 25 '12 at 21:10
    
Well, but then you need to define what Maintenance Mode plugin/code you'll be using... Is the login done in the frontend? If not, does the normal login screen is being redirected to the frontend? Anyway, less complicated would be create a dummy user and give the credentials to other visitors... –  brasofilo Jun 25 '12 at 21:14
    
I've been looking at the Maintenance Mode Plugin, but for me it really not an issue which plugin I'm using as long as I can get the functionality working. There will be a handful of users who can enable the maintenance mode but normal visitors can not access that functionality...And yes the idea is to redirect the normal login to a front-end enable page. Do you have any idea how I should go about...??? –  Pxl Jun 25 '12 at 21:23
add comment

1 Answer 1

up vote 0 down vote accepted

Based on Bainternet's answer to this question:
Save Theme Options (options.php) From The Frontend

The key is to know the name of the plugin option to Enable/Disable the Maintenance Mode.
In this example, it's named: my_maintenance_mode

<?php 
    if ( isset($_POST['mmode']) && isset($_POST['action']) && $_POST['action'] == "update_mmode" ) {
        if ( wp_verify_nonce( $_POST['theme_front_end'], 'update-options' ) ) { 
            update_option( 'my_maintenance_mode', $_POST['mmode'] );
        } else {
        ?>
            <div class="error"><?php echo 'update failed'; ?></div>
        <?php
        }
    }

    // DISPLAY FORM ONLY FOR THESE ROLES
    if( current_user_can( 'administrator' ) || current_user_can( 'editor' ) ) {
?>

<form id="save-mmode" name="save-mmode" action="" method="post">
<select name="mmode">
<?php $selected = get_option('my_maintenance_mode');
    <option>Enable/Disable Maintenance Mode</option>
    <option value="1" <?php if ( $selected == 1 ) echo 'selected="selected"'; ?>>Enabled</option>
    <option value="2" <?php if ( $selected == 2 ) echo 'selected="selected"'; ?>>Disabled</option>
</select>
<?php wp_nonce_field( 'update-options', 'theme_front_end' ); ?>
<input type="hidden" name="action" value="update_mmode">
<input type="submit" name="update-options" value="Save">
</form>

<?php
    } // END if(current_user_can)
?>
share|improve this answer
    
I think it might be 'mamo_activate' for this particular plugin. is there any other values I should change, its not activating, but maybe i have the wrong option... –  Pxl Jun 25 '12 at 22:18
    
Please, give a link to the plugin, even better to the trunk file, even much better paste the relevant block of code in your question... –  brasofilo Jun 26 '12 at 3:59
    
Maybe this will help... # Plugin name 'Name' => 'Maintenance Mode', # Author of the plugin 'Author' => 'Michael W&ouml;hrer', # Authot URI 'AuthorURI' => 'http://sw-guide.de/', # Plugin URI 'PluginURI' => 'http://sw-guide.de/wordpress/plugins/maintenance-mode/', # Support URI: E.g. WP or plugin forum, wordpress.org tags, etc. 'SupportURI' => 'http://wordpress.org/tags/maintenance-mode', # Name of the options for the options database table 'OptionName' => 'plugin_maintenance-mode', –  Pxl Jun 26 '12 at 16:49
    
The answer is in this update of yours..: plugin_maintenance-mode –  brasofilo Jun 26 '12 at 20:53
    
Hm...it's not working, ie the maintenance mode isnt enabled. Is there other values in that code that needs to be changed that is obvious to you but not to me? Should my theme name in there instead of theme_front_end for example...?? –  Pxl Jun 27 '12 at 8:37
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.