Prevent Multi-site : Site Title from being changed after signup

Hi.

Does anyone have a bit of ‘code’ that will stop the user of a ‘multi-site’ Site from changing the ‘Site Title’ (from within ‘Setting/General/Site-Title area), after ‘signup’ please?

i.e:-

Permanently freeze the first registered Site Title!!!!!!!!!!!!

Thanking you in advance.

Regards

johnv

  • Vinod Dalvi
    • WP Unicorn

    Hi Johnv,

    I hope you are well today and thank you for your question.

    To achieve this try using the attached small plugin by network activating it which contains the following code.

    function custom_update_field_blogname( $new_value, $old_value ) {
    if( $old_value != '' )
    $new_value = $old_value;
    return $new_value;
    }

    function myplugin_init() {
    add_filter( 'pre_update_option_blogname', 'custom_update_field_blogname', 10, 2 );
    }

    add_action( 'init', 'myplugin_init' );

    Best Regards,

    Vinod Dalvi

  • john
    • Site Builder, Child of Zeus

    Hi.

    Found a slight problem!

    Any new multi-site sign-up is being created with the unique site name, but the site title is always “My Site” (frozen as is desired) not the site name as in the URL.

    Hope this makes sense???

    Regards

    johnv

  • john
    • Site Builder, Child of Zeus

    Hi Vinod Dalvi.

    Do you have any advice as to how I can change your plugin so that the site title is not affected at/after signup, please?

    Currently all newly registered sites have the desired ‘site title’ converted to “My Site”, which is then ‘frozen’ (which is exactly our initial objective)!

    Your advice would be very much appreciated?

    Kind regards

    johnv

  • Vinod Dalvi
    • WP Unicorn

    Hi Johnv,

    Thank you for your reply.

    To resolve this problem, try using the updated version of the plugin attached to this reply which contains the following code.

    function custom_update_field_blogname( $new_value, $old_value ) {
    if( $old_value != '' && $old_value != 'My Site' )
    $new_value = $old_value;
    return $new_value;
    }

    function myplugin_init() {
    add_filter( 'pre_update_option_blogname', 'custom_update_field_blogname', 10, 2 );
    }

    add_action( 'init', 'myplugin_init' );

    Regards,

    Vinod Dalvi

  • john
    • Site Builder, Child of Zeus

    Hi Vinod Dalvi.

    Thank you so much! Just great!!

    But, can I push my luck and ask if you have some code to make a ‘condition’ for Super Admin to be excempted.

    I hope it is not too much to ask!!!

    Regards

    johnv

  • Vinod Dalvi
    • WP Unicorn

    Hi Johnv,

    Here’s the updated plugin version containing the below code that exempt the Super Admin.

    function custom_update_field_blogname( $new_value, $old_value ) {

    if( $old_value != '' && $old_value != 'My Site' && !is_super_admin() )
    $new_value = $old_value;
    return $new_value;
    }

    function myplugin_init() {
    add_filter( 'pre_update_option_blogname', 'custom_update_field_blogname', 10, 2 );
    }

    add_action( 'init', 'myplugin_init' );

    Cheers,

    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.