Assign a user role based on radio button check Ultimate Member - wordpress

I'm using Ultimate Member for my registration process and I've added a custom radio button to check if the user is a Contractor or not.
As default it would assign "Customer" role to new users, but I want it to assign the role "Contractor" when that radio button is checked.
I tried to go through Ultimate Member settings, nothing helped me, the only available rules in the registration form for the radio button are show and hide, there's nothing related to which role to assign !
Hope you can help me, thanks !

First of all, you should create the rol from UM->Profile->Add New Role.
You sholud create as many profiles you need.
After that, on Register form, you should add the "profile Radio Button".
The button configuration will show all roles your wordpress have. You should mantain those you want and delete from options which you don't
PD: BE CAREFULL... You can't change role names. If you do, the registration form will not show them.

Related

Drupal Entity Registration module - List of deleted registrations

I have events (sport trainings), created manually. Users can register for that events with Entity Registration module.
What I need is a list of deleted registrations. I can create a rule "after deleting a registration create a new entity" with a date field (when registration was deleted) and a field contains user. But problem is... I don't know, how to store name of that related event.
Is there a way to store a name or date of related event, when registration was deleted? How can I do it?
It has been a while since I have messed with entity registration, but if I am not mistaken, isn't there a registration state option?
This may be a bit of a workaround, but could you disable the ability for users to delete a registration outright, but allow them to change the state of their registration to a state called "Deleted"? That way you would still have the registration and still have all of the data associated with it.
For a more streamlined method, you could add a button or something that runs an action that changes that user's registration to state "Deleted" but no button to change it back, so they cannot un-delete (assuming you don't want them to be able to un-delete).

Cannot filter a view based on the field value

Drupal 7
Problem statement: Cannot filter a view based on the field value
I have a content type called support ticket
It has a field called assigned-to which has the list of users to whom the ticket will be assigned
I created a view for support ticket content
I have added a contextual filter Content: Assigned to, configured display based on “User ID from logged-in user”
Works fine for admin but not for other users
Can anyone please help me resolve this
The setting you're using in the view are perfectly fine. Couple of checks that you could do:
Make sure that the field assinged-to is a user reference field or an entity reference field reffering to the user entity.
Make sure there is value in the assigned-to field in some nodes for the current user you're logging in as.

External user invite (Share Alfresco)

i am asking if we can add an extrernal user to a group from the invite page. the idea is to affect directly a new user to a group (e.g: select Group from combo-box like for Role) and then click the button invite to get a new user with selected group.
how it could be done?
I do not think you can do this without any customization because unless user is part of alfresco you can not add them to group.
You should take a clue from this thread:
Alfresco Forum

Force anonymous to register before submitting a form. Drupal 7

I want to force anonymous to register an account before submitting the form.
So I have to allow permission for anonymous to access the form,
Then I use hook_form_FORM_ID_alter to edit form. Then I wanted to redirect submit button to another link if it is clicked by anonymous.(I still have no idea how to do it. It would be nice if anyone can tell me)
Is this the right solution?
For now,
I have a pop-up a login form (Modal forms and Facebook OAuth). In the form there is a register button. Then If user choose to register I want to keep the form that he have already input and show it after he confirm his email.
Thank you.
Off the top of my head, I would allow the form to be submitted either by an anonymous user or a registered one.
in my function MYMODULE_MYFORM_submit() I would check to see if the user is logged in.
If yes proceed as normal, if no, store the form, either in a temp SESSION variable or into a custom MySQL table and forward the user to login/register page (mysite.com/user) using drupal_goto('user')
once the user was registered you could then check for the existence of the form in the SESSION array or your MySQL table, and then carry on with the process as you would if the user had been logged in in the first place
Hope this makes sense or is of help

How to : required validator based on user role ASP.Net MVC 3

i have a form where i have the field "Real Cost" i want to customize its appearance and wither it should be validated based on user role.
to be more clear is say the client want to show his field in the form or details page and also make it editable for users in Roles "Senior Sales, Manager" but not other roles, so can anyone please guide me of the best way ?
should i write custom required validation based on user in role, and if so can you please provide the right implementation of it?
some may tell me create custom model for this, but i think it would be hassle plus the Roles will be dynamic so it is not predefined set of roles.
i hope i was clear enough
Security is definitely something that should be happening in the model or the controller but never in the View -- that is well beyond the View's scope of concern. Which is to display the data that the controller gives it.
To expand on #Wyatt you need to make all these decisions at the model level and then populate a 'View Model' with all the answers, which then can be used in the view to improve user experience.
In the ViewModel for this form, have a property IsRealCostEditable, which will be set by your service/model layer by checking the user's role. Now you can easily adjust the UI for that field.
You can create duplicate pages and one page can contain the view model which doesn't changes anything in the page... AND you can have an EDIT button which redirects to the editable page.
Make that page protected with authentication. SO you will asked to authenticate as your role before you can edit it
OTHERWISE.. there is no way your ViewModel can make decisions, its on the Service Layer.

Resources