CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • How to automatically assign role, or sync with authenticated role?
Pages: [1]

Author Topic: How to automatically assign role, or sync with authenticated role?  (Read 1739 times)

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
How to automatically assign role, or sync with authenticated role?
September 14, 2012, 04:13:20 pm
I'm running drupal 7.14 and civi 4.1 . I want to have new users automatically allocated a member role when they create an account. I've asked over on the drupal forum and modules logintoboggan, autoassignrole and rules have been suggested. I've tried them all - logintoboggan doesn't have that feaure. Autoassignrole and Rules modules both work if I disable the civiCRM profile included on my 'create an account' registration page. When I enable the profile both modules return an error rather than creating an account.

the reason I need to automatically assign a member role to new members is that civiCRM roles sync doesn't recognise the default 'authenticated' role - it will only sync with drupal roles that have been created.

Any suggestions on how to either get civi to recognise the authenticated role when creating sync associations, or to automatically assign a role whilst incorporating a civi profile in the user registration would be greatly appreciated as I've gone round in circles on this for most of the day :-(

thanks,
Shirley

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to automatically assign role, or sync with authenticated role?
September 15, 2012, 02:25:53 am
I may not understand your use case.
We have done the following - to give access to content based on a Role that is based on a Memberships status
Create a Role = Members
Use CiviCRM Members synch
Assign the Membership type and status to synch to your Members Role

But I am assuming that when you say 'member' you do mean someone who has been given a membership, and not just 'any contact'
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
Re: How to automatically assign role, or sync with authenticated role?
September 15, 2012, 03:31:09 pm
Yes, I've created a member role and these are people who have 'joined' by creating an account on the site. But I don't want to have to go in every few hours, check for new members and manually allocate them to a drupal 'member' role so that civi will sync it - I'd like it to happen automatically. The sync only recognises a drupal role, it doesn't allocate it. And civi sync doesn't recognise the default user status of 'authenticated'. It will create a matching contact record, but not allocate a member role - and the member role is required because access to content is based on the role and inclusion in civi groups is dependent of civi recognising that role.

Is this more a drupal/civi issue than a civi configuration issue ? Should I post my query in the 'using drupal with civi' part of this forum?

thanks
Shirley


petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to automatically assign role, or sync with authenticated role?
September 16, 2012, 01:10:43 am
Hi Shirley - i am still not understanding the flow here. Sounds like you are not using CiviMember.
WHen people create an account on your site they get Authenticated Drupal role - and will be creating their civi account.

Are there some people who need more access that that. If so what are they doing that specifies they need more access?

Not sure what the synching is that you are wanting. Maybe someone else will get it, but i don't, sorry
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 01:56:33 am
Hi, thanks for the response. It's probably my logic that's off here and/or my ability to explain what's happening in drupal/civi terms :-)  I am using civiMember. Maybe if I go back to what I'm trying to achieve it will be clearer why I'm having this problem:-

I have one free and 2 paying levels of membership. Each one gets different access permissions on the site.

The paying members go to a civiContribute page (that also creates a drupal account) then to paypal to pay their dues, then back to the site. Civi then adds them to the appropriate level members' group in civiCRM.   Drupal already has the different member roles created and civiRolesSync then syncs them to the relevent drupal paying member roles. Thus I end up with a list of drupal accounts with the correct paying member level noted against their names in the drupal list, as well as contact records allocated to the correct member groups. So this all seems to work okay.

The free membership signup goes to user/register which is the usual drupal 'create an account' page - this includes a civi profile to collect their first/last names as well as the usual user name and email. When they complete the form, civi creates a contact record (and adds them to a civi group for free members) and drupal creates a user account. BUT - the free members have nothing in the roles column on the drupal list, although drupal recognises them as authenticated users. But I have limited the authenticated role to more or less the same level of access as non-signed-in site visitors. I have defined a role of 'free' in drupal and allocated relevant access permissions. I want that group to be automatically assigned to anyone creating an account so that they have they correct access permissions. I thought that civiSync could do that, but 'authenticated' doesn't show in the drop down lists on civiSync so I can't match the two up :-(  Hence my search for a drupal module that would automatically allocate the 'free' role on signup.

Sorry, this is turning into a long post. But, explaining it seems to give me two clues about what I could do, or am doing wrong:-
1) I could forget about the 'free' role in drupal and simply reset the access permissions for the authenticated role to those needed for free members (because currently the authenticated role has no purpose). I don't think it would then need to sync in civiCRM because those free members would have the correct access in drupal and are already being allocated to the correct civi group.
2) I could use a civiContribute page for free members to sign up, with a contribution of NIL. Then I think civi could allocate the 'free' drupal role on submission of the civiContribute page. But I don't know how/whether that would work - does civiContribute understand that it doesn't go to paypal if the amount is zero? If no payment is made will it still allocate the drupal role?

I hope my problem is now clearer and wonder whether you think (1) or (2) might solve my problem, or whether there are other ways to achieve the same thing?

thanks for your patience with a novice
Shirley

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 03:06:41 am
if 'free members' sign up via Drupal user with a civi profile, you can set that Profile to join them to a group

sounds like you already do this

then use the CiviGroup Roles Sync to Sync Drupal Roles to CiviCRM Groups

which says 'if you are in Civi Group 'free members' give me the 'free members' role in Drupal

is that what you need?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 03:41:01 am
Yes, that's exactly what I need, but can't work out how to do it.

I go to configuration/civiGroup Roles Sync and then 'add association rule'.  It gives me a drop down list for civigroups. I choose the one for free members. Then I go to the drop down for Drupal roles and 'authenticated' is not an option. I can choose the 'free' member role - but there's no-one to sync with because new users are allocated the 'authenticated' role, not the 'free member' role when they sign up for an account. So civiSync is looking for 'free members' to sync with, not looking for authenticated users to whom it should allocate the 'free members' role (I think!)

So, I either need civiSync to list the authenticated role, or I need new users to be allocated the 'free' role. Or I need another way around this!

Shirley

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 03:57:46 am
But why do you need to synch with Authenticated?

They will all already have that role just by dint of having a Drupal account - that is what a Authenticated user is
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 04:33:46 am
The 'authenticated' role doesn't give new users the additional member access permissions. So, I don't want to sync with authenticated users - I want new users to be allocated the 'free member' role, and I want to do that automatically, rather than have to go into the drupal users list each time someone creates an account and manually allocate them the 'free member' role. It's the 'free member' role that gives them additional access to site content.

I can't find a way to do it unless I remove the civiCRM profile from the sign up page - then either the Rules or the Autoassignrole drupal modules will work.

I'm coming round to the view that I just give the authenticated role the 'free member' access permissions and that's problem solved - then I don't need to sync with civiCRM as they already have a contact record and have been joined to the right group.

I was avoiding doing that because I wanted to keep the authenticated role unencumbered in case I needed in the future to have a signed-in role that wasn't linked to membership. But I can see now that is going to make life even more complicated so changing authenticated role permissions is probably the best way.

thanks
Shirley

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 05:51:59 am
Quote from: ShirleyB on September 17, 2012, 03:41:01 am
I go to configuration/civiGroup Roles Sync and then 'add association rule'.  It gives me a drop down list for civigroups. I choose the one for free members. Then I go to the drop down for Drupal roles and 'authenticated' is not an option.
still feeling confused - above you say you can't find 'authenticated but you also seem to be saying you dont want to.

On the Profile used for Drupal user account - in Advanced Settings - is it configured to add people automatically to a civi Group - if so is that your 'free member' group
if so why can't you use the Group Role synch to say 'whoever is in the 'free member' civi group is to be given the 'free member drupal role'?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 08:56:22 am
Now I feel a complete idiot :-(  because the group/role sync is now working :-)

I started trying to solve this 'problem' because, despite having on the list of associations my free member group synced to the free member role, a couple of my test users had managed to create user accounts without being allocated to that role.

I therefore assumed that the sync between that group and that role was not working. But I clearly didn't think through the logic of that enough - the other roles/groups on the list were synced okay so what was wrong with that one? My other test users had signed up for paid memberships and had been automatically added to the right group and allocated the correct drupal role.

In trying to explain the problem here I'd concentrated on getting the correct role automatically allocated on creating an account, not on why that sync wasn't working - I assumed that I'd not done something and the fault was mine. In the last hour I've also tried explaining the problem to a non-drupal/civi colleague and in doing so realised that the sync should work, but apparently hadn't. I went back to the civiGroupRoles sync and resaved it - didnt change anything, just resaved. Then I went to two differnet browsers and signed up for test accounts. Both were automatically allocated to the correct civi group AND the correct drupal role .... yippeee!!!!

I still don't know why my testers were able to create accounts and not get allocated the roles but the important thing is that it works now! The moral of this story for me is that I should have thought the logic through, and tested the behaviour for myself.

Thank you for your patience in trying to understand and help with my 'problem'. I guess if I'd started with "this group should sync with this role, but it's not working", I'd have got different answers. I'm sorry to have wasted everyone's time but I think I've at least learned a bit about 'debugging' and 'problem clarification' in the process :-)

Shirley

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 09:15:13 am
No probs - we have all been there  ::)

also just to flag - and as reminder to others - synching does not usually show immediately - it occurs when the person next logs in

so if you see a person create an account, and go check their Roles - and it doesn't show as being set - it doesn't mean it isn't working - there is a synch manually that helps address this and help save us from despair sometimes
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

ShirleyB

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7.15
  • MySQL version: 5.5.27
  • PHP version: 5.3
Re: How to automatically assign role, or sync with authenticated role?
September 17, 2012, 02:41:11 pm
now it's working it's showing up straight away, whereas before it wasn't after a couple of days.

thanks again
Shirley

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • How to automatically assign role, or sync with authenticated role?

This forum was archived on 2017-11-26.