• Opgelost wzshop

    (@wzshop)


    Hallo,

    Is het mogelijk om de feature Application Passwords alleen beschikbaar te stellen voor admins? Ik had deze website erover gevonden: https://make.wordpress.org/core/2020/11/05/application-passwords-integration-guide/ maar hun code werkt niet voor mij?

    function my_prefix_customize_app_password_availability(
    $available,
    $user
    ) {
    if ( ! user_can( $user, 'manage_options' ) ) {
    $available = false;
    }

    return $available;
    }

    add_filter(
    'wp_is_application_passwords_available_for_user',
    'my_prefix_customize_app_password_availability',
    10,
    2
    );

    Is hier een oplossing voor? Bedankt, WZ

2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)
  • Thread starter wzshop

    (@wzshop)

    De bovenstaande code bleek toch te werken.
    Had te maken met een cache of wellicht dat de code niet werk, wanneer je een eerder ingestelde Application Password wilt gebruiken.

    Thread starter wzshop

    (@wzshop)

    For anyone also using the Woocommerce app on the mobile. The above function will not work, once authenticated. This means it is not possible to use the Woocommerce mobile app with the function above. You can use this function below to check the user by ID. This works, if you only want to allow the admin to use Application Passwords (for the Woocommerce app) and your user ID is 1:

    function my_prefix_customize_app_password_availability(
        $available,
        $user
    ) {
        if ( $user !== 1 ) {
            $available = false;
        }
     
        return $available;
    }
     
    add_filter(
        'wp_is_application_passwords_available_for_user',
        'my_prefix_customize_app_password_availability',
        10,
        2
    );
2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)