Wordpress only allows one role per user...help :)

Discussion in 'Integration' started by grantswaim, Mar 22, 2008.

  1. grantswaim

    grantswaim New Member

    Joined:
    Mar 16, 2008
    Messages:
    109
    I am setting up a Wordpress site that will use aMember to control registration and access to premium areas. I have it all set up except for one little problem...

    Apparently Wordpress does not allow a user to be assigned to more than one role. Since aMember controls access by assigning roles to users this is my problem. I planned on setting up a series of memberships with each level offering more content. I have used the "Role Manager" and "Disclose-Secret" plugin to accomplish this and it works well. For example from the Wordpress Admin CP I can change a user's roles and the content they see is controlled just as I planned.

    The problem is that I can't get aMember to assign a new role to a user. For example, I have a free subscription product named "Register" which assigns a user the role of "Subscriber". This allows me to start capturing some user information from visitors that do not want to purchase a premium content membership. They also must register before thay can comment on a post.

    After they have registered and then choose a premium content subscription (which assigns them the role of "Contributor") their role stays "Subscriber". Since Wordpress does not allow more than one role to be assigned to a user it seems to be blocking aMember from assigning a new role.

    Has anybody else noticed this or am I just not doing something right?

    One possible solution would be to have aMember delete a previous role so it can assign a new, higher ranking, role.

    Thanks in advance for any thoughts on this!
  2. darren

    darren Member

    Joined:
    Aug 22, 2006
    Messages:
    36
  3. grantswaim

    grantswaim New Member

    Joined:
    Mar 16, 2008
    Messages:
    109
    I have Wordpress 2.3.3 working fine with aMember 3.0.9 (also using the Wordpress plugin) except for the single role thingy.

    If you could expand more on what is not working, maybe I could make some suggestions.

    Yep, I am aware of the "level" based plugins such as this one. The problem I have with trying to use them is that the levels feature was replaced with "roles" in the 2.0 release of Wordpress. I would like to base my setup on current features not ones that are hanging around for legacy support.

    For example the plugin listed seems to be dead. The link is bad and I have poked around the web and can't find it. All of the plugins that are current (still supported and are being improved upon) are using the roles concept.

    I think the only way aMember is going to be able reassign a different role to a user is to unassign the current role first.
  4. grantswaim

    grantswaim New Member

    Joined:
    Mar 16, 2008
    Messages:
    109
    aMember Support Fixed This Problem

    I filed a support ticket with aMember about how Wordpress was not allowing the aMember plugin to reassign a role to a user after they had been assigned a role.

    In my case I had a subscription product set up for free site registration that assigned the user the Wordpress role of "Subscriber". This basically allowed them to comment to posts. I also had a subscription product (for a fee) set up that assigned them the role of "Contributor". I used a plugin in Wordpress (Secret-Disclose) that would show hidden pages to those with the role of Contributor.

    If they registered with the site and then later bought the membership, they would not be changed from Subscriber to Contributor in Wordpress.

    Alexander changed the Wordpress plugin to unassign a previous role before it assigned a new role. It now works perfectly. You can only assign a user to one role at a time, but that is a limitation of Wordpress, not aMember.

    Thanks aMember support!

    I assume this will be changed soon in the Wordpress plugin, so you might want to check into getting the latest version of the plugin if you want to be able to have more than one level of memberships.

    PS: darren (and anybody else) you can see this Wordpress / aMember integration at http://digitalliteracyproject.com You will see the interface to aMember in the login box and links in the top right corner.
  5. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    grant, nice looking site. are you calling the signup page from an include within a wordpress page or how did you set up your integration? Looks good!
  6. grantswaim

    grantswaim New Member

    Joined:
    Mar 16, 2008
    Messages:
    109
    Thanks, I am trying :)

    I am using a standard WP installation and the aMember/Wordpress plugin. I am using the Revolution theme (but that doesn't really matter).

    I used the script provided in the aMember manual and added a little table work to get things all lined up...

    Code:
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "Hello $au[name_f] $au[name_l]!<br>";
    print "<a href='/amember/iprofile.html'>Edit Your Profile</a><br>";
    print "<a href='/amember/imember.html'>View Account Info</a><br>";
    print "<a href='/amember/logout.php'>Logout</a>";
    } else { // user is not logged-in
    print "<form method=post action='/amember/login.php'>
    <table><tr><td align=right>Username:</td>
    <td align=left><input type=text name=amember_login size=10></td></tr>
    <tr><td align=right>Password:</td>
    <td align=left><input type=password name=amember_pass size=10></td></tr>
    <tr><td colspan=2 align=center><input type=submit value='Login'></td></tr></table>
    </form>";
    print "<a href='/amember/isignup.html'>Free Site Registration</a><br>";
    }
    ?>
    You will also have to add this one line of code as the first line in the header file:

    Code:
    <?php session_start(); ?>
    I also configured in aMember to always redirect to my home page at login and logout.

    When I tried to integrate aMember into my site by editing the aMember header and footer files I kept having issues with the php from Wordpress and php from aMember conflicting, so I integrated the aMember pages within WP with the iframe tag.

    I opened my WP homepage in a browser and copied the page source to a text editer. I replaced all the code between the "content" div tags (this may vary from theme to theme) with an iframe link that inserts the aMember page right into the WP page. Instant aMember theming!

    When yo do this and you link to an aMember page from a WP page you must link to one of these iframed pages that includes the aMember page as an iframe. So I ended up making three pages that include an iframe link to an aMember page. I called them isignup.html, imember.html, and iprofile.html. These are the only aMember pages that I link to directly from a WP page. You may notice these links in my code above.

    Once you are viewing one of these three iframed pages and click on links in the aMember part of the page, the new aMember page is displayed in the exsisting page.

    It worked pretty slick but with the iframe link you must set a height. I went with 600px. I end up with some extra space on some aMember pages and a scroll bar on a few, but for the most part it integrates fairly well.

    This is the bulk of the integration and I hope I explained this well enough.
  7. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Thank you for such a thorough explanation, this is a huge help and enough to keep me busy this afternoon :)

Share This Page