• Resolved wiredpinecone

    (@wiredpinecone)


    Hi Shea,

    Thanks for the great plugin. We’ve been shifting code from functions.php into the code snippets with varying results. Many snippets have worked, but implementation of the below is proving delicate.
    For example, the “Hide Password stuff” in the code below didn’t work at all. The Jetpack login is mandatory for our multisite.

    Would appreciate any tips or modifications you would recommend to get the below code to work properly when network activated on our multisite.

    Thanks in advance!

    // Activate Jetpack SSO Login module only
    function ds_auto_activate_sso() {
    return array( ‘sso’ );
    }
    add_filter( ‘jetpack_get_default_modules’, ‘ds_auto_activate_sso’ );

    // JetPack force wp.com login
    add_filter( ‘jetpack_sso_bypass_login_forward_wpcom’, ‘__return_true’ );

    // JetPack avoid local login when bumped by privacy plugin
    // Apparently this follows force wp.com login above so the two don’t conflict
    add_filter( ‘jetpack_remove_login_form’, ‘__return_true’);

    // DID NOT WORK Hide password stuff in edit profile
    From https://www.role-editor.com/hide-disable-wordpress-user-profile-fields/
    if (is_admin()) {
    add_filter(‘show_password_fields’, ‘show_password_fields’);

    function show_password_fields() {
    if (current_user_can(‘administrator’)) {
    return true;
    }
    return false;
    }
    }

    // DISABLE default WordPress new user notification emails
    // From (with corrections!) https://www.itsupportnotifiguides.com/wordpress/wordpress-how-to-disable-new-user-notification-emails/
    if (!function_exists(‘wp_new_user_notification’)) :
    function wp_new_user_notification($user_id, $plaintext_pass = ”) {
    return;
    }

    endif;

    https://www.ads-software.com/plugins/code-snippets/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi,

    Sorry for taking so long to address this. I’ve yet to debug everything in the snippet, but the hide password fields section seems to be working perfectly fine for me. With this snippet, the password section on user profiles is shown for administrators but shown for other users:

    if ( is_admin() ) {
    	add_filter('show_password_fields', function () {
    		return current_user_can( 'manage_options' );
    	} );
    }
    Plugin Author Shea Bunge

    (@bungeshea)

    For the Jetpack section, as far as I can see the jetpack_get_default_modules is only used to determine the initial active modules when the plugin is active.

    Instead, you can override the database option where the active modules are stored:

    add_filter( 'pre_option_jetpack_active_modules', function () {
    	return array( 'sso' );
    } );

    The other Jetpack filters seem to be working fine.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘problematic snippets network activated on multisite’ is closed to new replies.