WordPress.org

Ready to get started?Download WordPress

Forums

Updating "blogname" from a plugin (2 posts)

  1. jspicher
    Member
    Posted 3 years ago #

    Hello everyone,
    I'm very new to creating plugins to WP and l've been working through the codex tutorials. I've come to a point where l'd like to give the user the ability to modify the blogname and blogdescription from my custom plugin. I know these fields are already available in the general settings section, but just for the sake of learning lets say there was a good reason for wanting to do this.

    Now in my plugin's settings page l have:

    <form method="post" action="options.php">
    <?php settings_fields( 'baw-settings-group' ); ?>
    Blog Name<input name="blogname" type="text" id="blogname" value="<?= get_option('blogname'); ?>" class="regular-text" />
    Adsense code: <input name="bh_adsense_code" type="text" id="bh_adsense_code"  value="<?php echo get_option('bh_adsense_code'); ?>" class="regular-text" />
    <input type="hidden" name="save" value="true" />
    <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />

    When l change the values of the two fields, the bh_adsense_code gets' updated, but the blogname does not, can anyone explain why that is, and help me with a work around?

    Thanks to anyone who can help!

  2. jspicher
    Member
    Posted 3 years ago #

    Disregard, l figured it out. I needed to add:

    register_setting( 'baw-settings-group', 'blogname' );
    In my register_mysettings() function.

Topic Closed

This topic has been closed to new replies.

About this Topic