locked
Make New User default to Friend RRS feed

  • Question

  • User-758507629 posted

     

    I have been working on this problem all day.

      I would like to have a new registered user to become a "Friend" automatically. I have a folder that i want people to have instant access to once they have created an account.

    Friday, October 19, 2007 2:51 PM

Answers

  • User-1705717250 posted

    Did you add OnCreatedUser="CreateUserWizard1_CreatedUser" to the asp:CreateUserWizard ?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2007 12:49 PM
  • User-758507629 posted

    I got it now!!

    Thanks, it works great!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2007 1:33 PM

All replies

  • User-1705717250 posted

    Add the role to your create user wizard like so

     

    Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)
            Roles.AddUserToRole(CreateUserWizard1.UserName, "friend")
        End Sub
     

     

    Hope it helps
    Saturday, October 20, 2007 8:33 AM
  • User-758507629 posted

    Thanks, that looks right, but where do i put it?

    I tried adding it to the back code on my register.aspx.cs but i recieved errors. keep in mind i am using C#.

     thanks for your help

    Monday, October 22, 2007 8:59 AM
  • User-1705717250 posted

    Sorry missed the c# bit here you go, just add to your .cs page and all should be well

     

    protected void CreateUserWizard1_CreatedUser(object sender, System.EventArgs e) 
    { 
        Roles.AddUserToRole(CreateUserWizard1.UserName, "friend"); 
    } 
    

     

    Hope it helps

    Monday, October 22, 2007 10:49 AM
  • User-758507629 posted

    Still hasn't worked. I tried two different ways. The first ran ok, but I didn't get the correct results.

    And the second try returned an error.

    do you see anything wrong?

    Monday, October 22, 2007 11:32 AM
  • User-758507629 posted

    My screen shors didn't work so here is the two codes,

    using System;

    using System.Data;

    using System.Configuration;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    public partial class Register_aspx : System.Web.UI.Page {

     

    protected void CreateUserWizard1_CreateUser(object sender, System.EventArgs e)

    {

    Roles.AddUserToRole(CreateUserWizard1.UserName, "Friend");

    }}

     

    that one ran, but with no results. here is the second one.

     

     

    public partial class Register_aspx : System.Web.UI.Page {

    }

    protected void CreateUserWizard1_CreateUser(object sender, System.EventArgs e)

    {

    Roles.AddUserToRole(CreateUserWizard1.UserName,
    "Friend");

    }

    Monday, October 22, 2007 11:43 AM
  • User-1705717250 posted

    Did you add OnCreatedUser="CreateUserWizard1_CreatedUser" to the asp:CreateUserWizard ?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2007 12:49 PM
  • User-758507629 posted

    I got it now!!

    Thanks, it works great!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2007 1:33 PM