3

Is it possible to update wordpress blogname and blogdescription via Redux framework.

array(
    'id'        => 'blogdescription',
    'type'      => 'text',
    'title'     => 'Blog Description',
    'default'   => '',
),
Nathan Hagen
  • 10,750
  • 4
  • 24
  • 31
cbm
  • 77
  • 5

2 Answers2

2

You can use update_option(); function

update_option( 'blogname', 'New Value' );

update_option( 'blogdescription', 'New Value' );

Hooking on Admin

add_action('admin_init', 'update_my_site_blog_info');
function update_my_site_blog_info() {
    $old  = get_option('blogdescription');
    $new = 'New Site Title';
    if ( $old  !== $new ) {
        update_option( 'blogdescription', $new  );
    }
}

EDIT:

I guess its better this way,

add_filter('redux/options/[your_opt_name]/compiler', 'update_my_site_blog_info');
function update_my_site_blog_info() {
    $new = 'New Site Title';
    update_option( 'blogdescription', $new  );
}

then your field needs to enabled compiler

array(
    'id'        => 'blogdescription',
    'type'      => 'text',
    'title'     => 'Blog Description',
    'default'   => '',
    'compiler'  => true,
),
silver
  • 2,573
  • 1
  • 12
  • 26
1

Thanks for the help, i did like this to make it work.

add_action('init', 'update_my_site_blog_info');
    function update_my_site_blog_info()
    {
        global $opt_keyname;
        $check = array('blogdescription', 'blogname');
        foreach($check as $key)
        {
            if ( get_option($key)  != $opt_keyname[$key] )
            {
                update_option( $key, $opt_keyname[$key] );
            }
        }
    }


Redux::setSection( $opt_name,
        array(
            'title'     => 'Basic Settings',
            'id'        => 'basic_settings',
            'fields'    => array(
                array(
                    'id'        => 'blogname',
                    'type'      => 'text',
                    'title'     => 'Blog Title',
                    'default'   => get_option( 'blogname' )
                ),
                array(
                    'id'        => 'blogdescription',
                    'type'      => 'text',
                    'title'     => 'Blog Description',
                    'default'   => get_option( 'blogdescription' )
                ),
            )
        )
    );
cbm
  • 77
  • 5