Last active
August 29, 2015 14:07
-
-
Save roine/3cf9dc253d21cbbe8797 to your computer and use it in GitHub Desktop.
wp have a checkbox in option page to be user specific saved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'admin_init', 'register_modal_email_settings' ); | |
function register_modal_email_settings() | |
{ | |
if( !get_option( $user->user_nicename . '_plugin_options' ) ){ | |
register_setting( 'section_email_modal', $user->user_nicename . '_plugin_options', '0' ); | |
} | |
add_settings_section( 'section_foo', 'Foo settings', 'foo_desc', 'foo' ); | |
add_settings_field( 'bar', 'Bar field', 'bar_option', 'foo', 'section_foo' ); | |
} | |
function foo_desc() | |
{ | |
return 'Description'; | |
} | |
function bar_option() | |
{ | |
$user = wp_get_current_user(); | |
$checked = $this->email_modal_settings[$user->user_nicename.'_plugin_options'] ? 'checked' : ''; | |
$name = $this->plugin_slug."[".$user->user_nicename."_plugin_options ]"; | |
?> | |
<input type="checkbox" <?php echo $checked ?> name="<?php echo $name ?>" /> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment