WordPress.org

Ready to get started?Download WordPress

Forums

Create temporary user with Subscriber role (4 posts)

  1. Wordletz
    Member
    Posted 1 year ago #

    Hi, first some background (skip ahead if tl;dr). I'm working with CAS (a single sign-on protocol) and WordPress. The sign-ons work but only when I create a user in wordpress with the same login_name as their username in CAS. This works great for admin accounts and people I want to have greater access, but I would like to take advantage of the authentication CAS is already doing for the non-privileged users. This would be great for things like event signups, I won't have to validate emails and create users because the users in the CAS have full names and emails already associated with it that are authenticated much more rigorously than I can expect users to want to go through just to sign up for an event.

    So wpcas provides a method to provision users, I could create a user for each one, but my site isn't nearly as strict with security as the host for the CAS is. Having a list of every user/email that's ever visited my site sitting there waiting to be taken would be a problem. So what I want to do is create a temporary user with the Subscriber role. Is there a way to do this without adding them to the database? something like
    set_current_user(new WP_User($user, $user@site.com)) ?

  2. bcworkz
    Member
    Posted 1 year ago #

    You could possibly create an anonymous user by automatically creating a user by feeding the routine a serialized username and email, but there is no way to do so without adding it to the database. Thus you would need a scheduled task to routinely delete anonymous users that are not currently logged on.

  3. tibodut
    Member
    Posted 1 year ago #

    Hi,
    I'm also working with CAS and so do you, I would like to grab information from CAS for non-privileged users.
    What have you decide Wordletz? What solution have you choose? (if there is...)

  4. Wordletz
    Member
    Posted 1 year ago #

    I made a provision script to automatically create a user with their information from CAS (just the username and email), and then I have a cron job that removes them after a certain period of time.

Topic Closed

This topic has been closed to new replies.

About this Topic