Adding some other fields in sharepoint 2013 fba pack membership request form

Feb 20, 2013 at 9:16 AM
Hello ,

I Need to add some more fields in Membership request form fields are bellow.

Organisation
Designation
Work phone
Mobile Number
Resistered For : this is roles (Check Boxes)

Please Guide me how to Add these Fields.
Coordinator
Feb 20, 2013 at 2:34 PM
I usually add the fields to the User Information List: http://zimmergren.net/technical/sharepoints-hidden-user-list-user-information-list

Then I modify the web part templates to include the new fields.

Then I modify the web part / membershiprequest class to save the new fields.
May 7, 2013 at 10:19 AM
Hello,
I would like to register users with other properties like date of birth, Phone, City along with the current User Name, First Name, Last Name, Email

We have a lot of trouble doing this

Can you help us?
Coordinator
May 7, 2013 at 1:06 PM
Sure - as a general guide for doing it yourself, I'll usually search the code for all instances of an existing field, like email, and then copy that code and adapt it for the new fields being added.

If you'd like us to add the custom fields for you, it can usually be done within the time included with the support plan, which can be purchased here:
http://www.visigo.com/purchase.html
Jun 28, 2013 at 10:16 AM
Hello,

I made the password fields visible in the form, so that the user cn choose his own password, but even then the system creates the password for the user itself.

Where can I change this setting.

Many thanks.
Coordinator
Jun 28, 2013 at 12:55 PM
There's a setting for 'auto generate password' on the web part. Just edit the web part and change the setting. It will then show the field and save the password.

Note that this setting does not work if 'Review membership requests' is on, as that would require the pw to be stored in the membership review list, which would be insecure.
Jun 30, 2013 at 4:12 PM
Thank you very much for your fast response always, really appreciate.
I changed the setting and it works.

Is there a way to login the user automatically after creating account successfully.

I just wanted also to use the e-mailadres as username, instead of a username.
Do you know where I can change the setting in the code avoiding to change it in all occurences?

Many thanks again Chris for providing this excellent tool.

Nour Din
Coordinator
Jun 30, 2013 at 6:56 PM
There's also an auto login setting in the web part properties. It also only works with Review Membership Requests turned off.

As for the email address, there's no setting that you can change in the code. You can use email addresses as usernames - but of course the user can't change their username if their email address changes.
Jul 1, 2013 at 4:07 PM
Many thanks again Chris.

autologin works.
However the username is not visible in the right upper corner after performing auto login (not the case if I login with the login form).
Strange thing is that I see only the arrow where I can choose to sign out or personalize the page.

I also tried to grab the username and e-mailaddress. .

I tried :

System.Web.Security.Membership.GetUser().Email.ToString()

and got error on fba.

and

SPContext.Current.Web.CurrentUser.Email doesn't returns a value for fba.

Do you now what I am missing here ?

Nour Din
Coordinator
Jul 3, 2013 at 12:45 PM
SharePoint uses the SharePoint user's "Name" field to populate the value in the top right. This is what's happening with your custom development right? Because out of the box, the webparts and management pages should set these values and they should be displayed in SharePoint.

SPContext.Current.Web.CurrentUser.Email should work, assuming you're running in the context of a logged in user and the email address has been set. If you're not running in the context of a logged in user, you'll have to use something like this to get the user:
this.Web.AllUsers[Utils.EncodeUsername(userName)];

Same thing goes for the membership functions - they'll never know who the current user is, because SharePoint doesn't use the standard membership authentication cookie. You'll need to do something like this: GetUser(userName,false).

I would suggest you deploy the standard fba pack, and then you debug it with Visual Studio to see how it works.
Jul 4, 2013 at 9:37 AM
You are right. I created a new simple web part for testing and now everything works. So the problem was with my own webpart.
SPContext.Current.Web.CurrentUser.Email works.
And also the name field is used in the top right of the sharepoint site.

What I am creating is the following :

I use the fba pack and made some changes to the settings.
When the user creates his account he should be redirected to a form (a web part that I created) where some of the fields of his FBA membership account are already filled in.

The most important is the e-mailaddress, which now is ok.

I am now searching for the following :

After registering successfully the user must be redirected automatically to a page that I define (my form).
Populate in my form the firstname and lastname in seperate fields.
Grab the UserId (=guid) from the membership database.

I also changed the web config for the complexity of the passwords but still the systems asks for Non-alphanumeric characters.
Coordinator
Jul 4, 2013 at 1:07 PM
Set MinRequiredNonAlphanumericCharacters to 0 and you shouldn't have to input any non alphanumeric characters. You have to make sure you make the change everywhere though - securetokenservice and all web.configs for all web applications (or the machine config if you define it there).

Why grab the guid from the membership database? I'd just use the api to read and write to membership. Are you storing your profile properties in there? Usually I just store them in the SharePoint user profile (unless they need to be used across multiple site collections).

You may also find it easier to just modify the membershiprequest web part and add the fields that you need, and ask the user for them at the time of registration instead of redirecting them to another page. But either should work.
Jul 7, 2013 at 6:33 PM
Edited Jul 7, 2013 at 6:38 PM
Thanks Chris,

It was indeed the machine.config that I missed.

I wanted to reuse some of the users profile information to save it in Microsoft Dynamics CRM.
Avoiding that the user has to fill in information that he already provided on time of registration.
But I didn't find the code for the redirect after user has successfully registered.
Coordinator
Jul 7, 2013 at 7:33 PM
If you're saving the profile information to the db, you'll probably want to look at the profile providers:

http://msdn.microsoft.com/en-us/library/014bec1k(v=vs.100).aspx

Like the membership provider, it provides an api you can code against to read and update a user's profile information.
Jul 11, 2013 at 10:57 AM
Thanks for the information.
What I didn't find however is where I can redirect the user to a page that I define after successfull registration (I enabled the autologin).
Are there also plans for a login web part for the FBA pack (for example on a page which allows anonymous access) instead of using/changing the default sign-in page.
Coordinator
Jul 11, 2013 at 12:15 PM
There's a "Finish Destination Page Url" property on the web part that you can use to redirect the user once they've successfully registered.

Although I would like to do a login web part in the future, it won't be in the near future.
Jul 14, 2013 at 7:20 PM
Ok redirecting works, thanks.

I have a strange issue.
When a user registers successfull an autologon is performed.
Firstname and Lastname are then shown in the right top corner. The user is redirected to my own web part and the email address is shown in a field using SPContext.Current.Web.CurrentUser.Email.
However when the user after that logs on with default sharepoint login page it is the username that is shown in the right top corner.
The emailaddress in my own webpart is blank.

Do you what could be the problem ?
Coordinator
Jul 15, 2013 at 12:39 AM
The name and email address is taken from the SharePoint user's profile. The user will have to update their profile with the information and it will show up.

Also, the profile is stored at the site collection level. So if they login to a separate site collection, that information won't be on their profile.
Aug 19, 2013 at 8:24 AM
if i want to add ""Work phone"" field to the Membership Request
How can i add'it ???

thanks
Coordinator
Aug 19, 2013 at 1:52 PM
I usually add the fields to the User Information List: http://zimmergren.net/technical/sharepoints-hidden-user-list-user-information-list

Then I modify the web part templates to include the new fields.

Then I modify the web part / membershiprequest class to save the new fields.
Aug 27, 2013 at 6:38 AM
Edited Aug 27, 2013 at 9:15 AM
hello

If you please,
i want examples about : < how to add New Field to the MemberShip Request WebPart ? >,

i read your Post above but i don't understand really how to add it.


Thank you
Coordinator
Aug 27, 2013 at 2:47 PM
Sorry, I don't really have any specific examples. Are you a developer? Because this is something that really needs to be done by a developer. It's not something configurable that can be done in a few minutes - a lot of code has to be changed. The best way to learn to do it would probably be to download the source code:
https://sharepoint2013fba.codeplex.com/releases/view/100792
And then search the source code for "email" - and then follow the patterns in the code that were used to input/save the email address to add your new field.

If you need some customization done to the FBA Pack, we do provide that. See here:
http://www.visigo.com/purchase.html
The hours included with the support plan would definitely cover adding "Work Phone" to the membership request.
Sep 28, 2013 at 11:04 AM
Hello Chris,

Can I redirect the user to my own page immediately after successfull registration so that he doesn't see the page with the success url first ?
I have set the "Finish Destination Page Url" but the user still has to click on Continue Button to get this page instead of going directly to my custom page.

Thanks.
Coordinator
Sep 29, 2013 at 11:32 AM
Sorry, but the user does still have to click the Continue button to get to this page. It uses ASP.Net's CreateUserWizard control, and is just following the default workflow for it.
Sep 29, 2013 at 12:32 PM
ok, thanks for your quick response anyway.
I disabled Review Membership and enabled auto login.
How can I prevent the user from getting the e-mail with his username and password.
I only want to send an e-mail on change password or on forget password. Is this possible ?

Upon registration we don't ask the user for his firstname and lastname, but redirect him to a web part form that we created and which stores his profile information in our CRM. It is there that the user fill in their name. Can you please guide me how to set the Display Name and e-mailaddress in Sharepoint for the FBA? to grab the e-mail address from the fba I use SPContext.Current.Web.CurrentUser.Email but I didn't find how to change it.

Many Thanks!
Coordinator
Sep 29, 2013 at 12:59 PM
You can't prevent the email from going out. You can change the contents of it though in FBA Site Configuration, so that it doesn't include the password.

As for updating the display name and email address - check the fba user management edit user page in the code, it has all the code to do that.
Sep 29, 2013 at 4:53 PM
Hello,

I imported the Utils class in my own webpart.

I tried with this code but got an error

string userName = SPContext.Current.Web.CurrentUser.LoginName;
            MembershipUser user = Utils.BaseMembershipProvider().GetUser(userName, false);
            user.Email = emailaddress.Text;

                           Utils.BaseMembershipProvider().UpdateUser(user);
But it throws the error : Object reference not set to an instance of an object

i also didn't find the property for the Name to change it.

Do you know what I missing here. thanks for your help
Coordinator
Oct 1, 2013 at 2:45 AM
I'm not sure - that looks okay. It could possibly be null if there's no fba membership provider configured for the web application you're running on. I'd suggest debugging it and stepping through - then you can see exactly where the problem is.