Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profile_update #5

Open
geepie opened this issue Oct 20, 2018 · 1 comment
Open

profile_update #5

geepie opened this issue Oct 20, 2018 · 1 comment

Comments

@geepie
Copy link

geepie commented Oct 20, 2018

If a user was created before wp-ldap is activated, the user is never update because it was never created in ldap.

profile_update should create the missing LDAP entry.

Please find the updated code

        $sb = self::getSearchBaseDN();
        $LDAP->setBaseDN( $sb );
        $search_results = $LDAP->search(
            '(&(objectClass=inetOrgPerson)(uid=' . API::escape_filter( $WP_User->user_login ) . '))'
        );

        if ( 1 > count( $search_results ) ) {
            $LDAP_User = new \WP_LDAP\User();
            $LDAP_User->setWordPressUser( get_userdata( $user_id ) );
            $LDAP->add(
                $LDAP_User->getEntityDN( $sb ),
                apply_filters( self::prefix . 'user_to_entity' , $LDAP_User->wp2entity() )
            );
        } else {
            $LDAP->modify(
                $LDAP_User->getEntityDN( $sb ),
                apply_filters( self::prefix . 'user_to_entity', $LDAP_User->wp2entity() )
            );
        }
@fabacab
Copy link
Owner

fabacab commented Oct 20, 2018

Thanks, can you create a pull request for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants