Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter frontiermedia

    (@frontiermedia)

    Hi guys,

    Thanks for the replies. Working now, here’s the amended code for anyone who stumbles upon this in the future:

    <?php
    /*
    Plugin Name: Showcase Controller
    Plugin URI: http://frontiermedia.net.au
    Description: Allows control of the showcase page.
    Version: 0.1
    Author: Sam Mclean
    Author URI: http://frontiermedia.net.au
    License: GPL2
    */
    
    add_action( 'personal_options', 'showcase_options' );
    
    function showcase_options ( $user ) {
    
    $currentStatus = get_the_author_meta( 'showcase_enabled_bool', $user->ID );
    if ($currentStatus == 1) {
    $currentStatus = "enabled";
    } else {
    $currentStatus = "disabled";
    }
    if ( !IS_PROFILE_PAGE && !is_network_admin() ) :
    ?>
    <h3>Showcase Settings</h3>
    
    <table class="form-table">
    <tr><th><label for="showcase-enabled-bool">Enabled for showcase?</label></th>
    
    <td>
    <input type="radio" name="showcase-enabled-bool" value="1"<? if ($currentStatus == "enabled") { echo " checked"; } ?>> Yes  
    <input type="radio" name="showcase-enabled-bool" value="0"<? if ($currentStatus == "disabled") { echo " checked"; } ?>> No<br>
    
    </td></tr>
    
    </table>
    <?
    else:
    ?>
    <h3>Showcase Settings</h3>
    
    <table class="form-table">
    
    <tr><th><label>Enabled for showcase?</label></th>
    
    <td>
    Your profile is currently <b><? echo $currentStatus; ?></b> for showcase listing. Contact an administrator to change this setting.
    </td></tr>
    
    </table>
    <?
    endif;
    
    }
    
    add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
    
    function my_save_extra_profile_fields( $user_id ) {
    
    	if ( !current_user_can( 'edit_user', $user_id ) )
    		return false;
    
    	/* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
    
    	if ($_POST['showcase-enabled-bool'] == 1) {
    	$showcase_input = 1;
    	} else {
    	$showcase_input = 0;
    	}
    	update_usermeta( $user_id, 'showcase_enabled_bool', $showcase_input );
    }
    ?>
Viewing 1 replies (of 1 total)