samaphp / acf-login

Advanced Custom Fields: Login. A Wordpress login that will help you pick a custom user field as a login field instead of the username or email.
https://wordpress.org/plugins/acf-login
GNU General Public License v2.0
3 stars 0 forks source link

Doesnt support ACF pro #1

Open tridentmarketinguk opened 1 month ago

tridentmarketinguk commented 1 month ago

Hi, I'm using this on my site, however it didnt support ACF Pro so I just changed the code to check that instead of ACF.

Also, it wouldnt show any fields so I had to change the main code use the ACF get fields call:

` public static function get_options() { // The fields that the user can pick as a custom user login field. $field_options = [];

$field_groups = acf_get_field_groups();

if ( !empty($field_groups) ) {
    foreach ( $field_groups as $field_group ) {
        // Check if the field group's location is set to display on the user form
        if ( isset( $field_group['location'] ) ) {
            foreach ( $field_group['location'] as $location_rules ) {
                foreach ( $location_rules as $rule ) {
                    if ( $rule['param'] == 'user_form' ) {
                        // Now fetch the fields for this group
                        $fields = acf_get_fields( $field_group['key'] );

                        if ( !empty( $fields ) ) {
                            foreach ( $fields as $field ) {
                                $field_label = $field['label'];
                                $field_id = $field['name'];
                                $field_options[$field_id] = $field_label;
                            }
                        }
                    }
                }
            }
        }
    }
}

return $field_options;

}`

tridentmarketinguk commented 1 month ago

I did try to set this:

if ( is_admin() && current_user_can( 'activate_plugins' ) && ( is_plugin_active( 'advanced-custom-fields/acf.php' ) || is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) ) {

but for some reason it the alert still shows - whereas if I just add

`if ( is_admin() && current_user_can( 'activate_plugins' ) && 
( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) ) {`

this works...