• WordPress automatically assigns USER_ID to the new registered USER. I am actually using ‘optional content plugin’ to show each ID their respective download link on their “WELCOME PAGE” immediately after they become user on my site. The download link for each user is different.

    I am looking forward for a solution to assign different “USER_ID range” to different “WordPress Role”

    For e.g. My membership plugin allows the following roles by default:

    S2MemberLevel1 (User ID may range from 1000-19999)
    s2MemberLevel2 (User ID may range from 20000-29999)
    S2MemberLevel3 (User ID may range from 30000-39999)

    The first member of “S2memberlevel1′ should automatically be assigned ID#1000 and the second member should be assigned ID#1001 and so on. The same should apply for each role based on their “specified ID-range”.

    This way it will be easy for me to list download links one by one for each role/level.

    Your help would be appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t think it’s a good idea to override the WP auto-assigned user IDs. It may not even be possible. Sure, you could directly send an UPDATE query to assign a new ID, but you’d have to be sure to change all such related IDs everywhere in the DB. I’m not convinced this can be reliably done.

    If you really must have sequential IDs, I recommend you maintain your own set of IDs separate from the WP user IDs. Call them “member_id” or something to prevent confusion. To determine the next available member_id in a range, query for that range, but order descending and limit 1. The member_id returned will be the highest assigned in the range, just increment by 1 for the new member_id.

    Are you sure you really need ID ranges and sequential IDs? This sounds like a human sense of order which has no meaning in a SQL database. The fewer arbitrary constraints in the data, the better off you are. Why does a certain role require a certain ID range. Isn’t the fact a user has this role enough?

    I do understand this would make it easier for you to list download links. If you were doing so manually, I get it. But if the list is generated by script, I don’t see the point. The script can just as easily list randomly assigned links as sequential links.

    I’ll help you do what ever you want, but I think you should revisit your organization scheme, it seems more constrained than it needs to be. If you are willing to describe what you are actually trying to do, I may be able to suggest a good approach from a DB perspective, not a human perspective. Only if you’re willing though, no pressure.

    Thread Starter juliereader

    (@juliereader)

    What I am trying to do:

    Let’s suppose I am selling unique articles to my customers. I need them to be my member on my site.

    I have 3 membership level/roles and 1500 unique articles in inventory:

    S2Memberlevel1 (Silver)-> 500 articles of 400 words each
    S2Memberlevel2 (Gold) -> 500 articles of 800 words each
    S2Memberlevel3 (Platinum) -> 500 articles of 1200 words each

    Each (500) set of articles are placed in a separate folder for level identification.

    Right now what I am trying to do is to place (manually) 1500 downloadable links on the CUSTOMER CLIENT DASHBOARD page. It should display only ONE DOWNLOADABLE LINK at a time based on following conditional:

    i) Role
    ii) Specific USER-ID

    But since WordPress doesn’t make different sequential user IDs for each role that’s why I am not able to execute this idea. : (

    ===========

    Another idea may be is to install new wordpress for each role in different folders. This way it will create new database each time each having its sequential IDs… But for that I’d need someone to design and a universal LOGIN PAGE for each blog. I don’t know if it is a good idea?

    ===========
    Do you have anything in your mind as an alternative to execute my need?

    Thread Starter juliereader

    (@juliereader)

    P.S. What if I add a custom field to each role’s registration form and add a sequential numeric value? Where can I find such script? And how to tell optional content to show content based on my “custom-id” instead of user-id now?

    I concur with @bcworkz, attempting to impose structure upon the WordPress assigned ID numbers is bound to end in tears. What if someone wants to upgrade or downgrade ? and so on. Also please be aware that your clients (level 1/2/3) will almost certainly still have WordPress roles of SUBSCRIBER.

    As @bcworkz suggested, you will be well served by establishing a new table for your membership levels, in it key on WordPress ID and have level etc as additional fields, you will be able to use an SQL JOIN to fetch the user details and new fields in the same query.

    Moderator bcworkz

    (@bcworkz)

    (Ross, thanks for chipping in – 2 heads are better than one 🙂 )
    Julie,
    Manually place 1500 links?!! Oh my, that alone calls for a script. You don’t code at all, correct? That would be fine, it’s just that most people who post in this sub-forum have at least some coding aptitude. I’m just trying to assess who I’m dealing with.

    I think your main organizational component should be the file resources, as you suggested, separate folders for the various levels. Additionally, the file resources should be sequentially numbered. If that’s impossible, a lookup table would be needed to keep track of what comes after what.

    Then each user’s level and where they are at in the sequence (a “bookmark” let’s say) could be simply maintained in user meta. Your page template that offers the next download for any particular user can easily determine what’s next from the level and bookmark alone.

    Because the downloads have intrinsic value, security is very important. It’s critical no one can access a file who does not have permission. It’s also important for those that do have permission to be able to access their resource without any glitches. The two goals are often at odds.

    The download permission aspect, as well as collecting payments can be handled by some sort of e-commerce plugin. WooCommerce is very popular (not an endorsement, just saying) and it does have a download component. It’s more of a browse for what you want, then buy it sort of approach. It may be overkill for your needs. There should be other options available.

    What ever plugin you decide on, there will be some aspect requiring some custom coding. You can easily hire someone to do this for you. While it’s too much to expect a freebie code out of these forums, I don’t see this being a big project either. It should be money well spent.

    It’s not allowed to solicit or offer paid work in these forums, but there are other sites that are specifically for this. You could try starting with http://jobs.wordpress.net/ . Whoever you end up hiring could likely have a different approach in mind than I have. There’s a number of valid approaches. It’s best to take the advice of the person to whom you’re paying due to their expertise.

    Thread Starter juliereader

    (@juliereader)

    @bcworkz
    I want to contact you.
    Please email me over here: juliereader(at)gmail(dot)com

    Moderator bcworkz

    (@bcworkz)

    Message sent yesterday, subject is the same as this thread. If you’re not seeing it, check your spam folder. If you just haven’t gotten around to replying, don’t worry, no rush.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Specify USER_ID range for each ROLE in wordpress’ is closed to new replies.