Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rich Green 2246 posts 4008 karma points
    Mar 29, 2010 @ 18:01
    Rich Green
    1

    Create a new member via contour?

    Hi,

    Is it possible to create a new member using Contour, if so are there any examples anywhere?

    I need to create a simple registration form that has a extra data per member, like telephone number, job title etc. (these are set up as properties of the member type).

    Many thanks

    Rich

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 29, 2010 @ 20:56
    Dirk De Grave
    0

    Rich,

    You can create your own workflow type which takes the form fields and based on that info creates a new member using the available member api or most preferable the membership api.

    Can' really show an example, but think the developer docs do have some examples on custom workflows (p11 - Adding a workflow type to Umbraco Contour)

     

    Hope this helps.

    Regards,

    /Dirk

  • Rich Green 2246 posts 4008 karma points
    Mar 29, 2010 @ 21:15
    Rich Green
    0

    Hey Dirk,

    Thanks for your reply, however if I need to write some .NET to interface with the API I may was well just write a registration form in a user control and access the API there.

    There doesn't seem to be a easy way to create a custom registration form, just seems like Contour would be a good place for it?

    Many thanks

    Rich

  • Harald Ulriksen 207 posts 249 karma points
    Mar 31, 2010 @ 01:44
    Harald Ulriksen
    2

    Hi,

    here's an example workflow. It features configurable membertypes. Note that it does use email as login name.

    using

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.Linq;

    using

     

    System.Web;

    using

     

    Umbraco.Forms.Core;

    using

     

    umbraco.cms.businesslogic.member;

    using

     

    umbraco.BusinessLogic;

    namespace

     

    Ulriksen.Silhouette

     

    {

     

     

    public class AddMemberWorkflow : WorkflowType

    {

     

    public override Umbraco.Forms.Core.Enums.WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)

    {

     

    string email = record.RecordFields.RecordValue("E-mail");

     

    string name = record.RecordFields.RecordValue("First name") + " " + record.RecordFields.RecordValue("Last name");

    Library.

    XsltLibrary.CreateMember(email, name,int.Parse(MemberTypeId),int.Parse(CreateMemberGroup));

     

     

    return Umbraco.Forms.Core.Enums.WorkflowExecutionStatus.Completed;

    }

     

     

    public override List<Exception> ValidateSettings()

    {

     

    throw new NotImplementedException();

    }

     

    public AddMemberWorkflow()

    {

     

    this.Name = "Add member workflow";

     

    this.Id = new Guid("15d2f92f-2134-43fb-bd13-35120f26997a");

     

    this.Description = "This will create a member if one does not exist.";

    }

    [Umbraco.Forms.Core.Attributes.

    Setting("MemberType",

    description =

    "Membertype alias for new members",

    control =

    "Umbraco.Forms.Core.FieldSetting.Pickers.MemberType")]

     

    public string MemberTypeId { get; set; }

    [Umbraco.Forms.Core.Attributes.

    Setting("CreateMemberGroup",

    description=

    "Default member group",

    control =

    "Umbraco.Forms.Core.FieldSetting.Pickers.MemberGroup")]

     

    public string CreateMemberGroup { get; set; }

    }

    }

    The support methods

     

     

    public

     

    static int CreateMember(string email, string name,int memberTypeId,int memberGroup)

    {

     

    Member member = Member.GetMemberFromLoginName(email);

     

    User author = new User(0);

     

    if (member == null)

    {

     

    MemberType memberType = new MemberType(memberTypeId);

    member =

    Member.MakeNew(name, memberType, author);

    member.LoginName = email;

    member.Email = email;

    member.Password =

    DateTime.Now.Ticks.ToString();

    }

     

    if (!member.Groups.ContainsKey(memberGroup))

    member.AddGroup(memberGroup);

    member.Save();

     

    return member.Id;

    }

     

    public static string RecordValue(this Dictionary<Guid,RecordField> fields,string labelName)

    {

     

    if (!fields.Values.Where(value => value.Field.Caption == labelName).Any())

     

    return null;

     

    else

     

    return fields.Values.Where(value => value.Field.Caption == labelName).First().Values.FirstOrDefault().ToString();

    }

    Hope this helps,
    Harald.

  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Jul 02, 2010 @ 12:00
    Ali Sheikh Taheri
    0

    Thanks a lot Harald and Drik. I will have a look on the document and aslo the code (Harald) and will let you know the progress.

    your quick reply is much appreciated.

     

     

  • bob baty-barr 1180 posts 1294 karma points MVP
    May 10, 2011 @ 22:28
    bob baty-barr
    0

    @Harald..

    i am having trouble getting your sample code to work out for me... i am NOT a developer, but have access to visual studio... getting various errors related to Library, Error    3    Expected class, delegate, enum, interface, or struct the section regarding .RecordValue

    plus the support methods... not sure where they go, etc. any guidance here would be greatly appreciated!

  • Yannick Smits 321 posts 718 karma points
    Dec 21, 2011 @ 21:47
    Yannick Smits
    1

    for googlers stumbling on this thread: 
    http://www.nibble.be/?p=107  

  • Anthony Candaele 1197 posts 2049 karma points
    Dec 28, 2011 @ 20:08
    Anthony Candaele
    0

    Hi,

    I have read the Nibble blog post (http://www.nibble.be/?p=107)

    The problem I'm facing though is that I have two member types: 'jobseeker' and 'employer'

    Based on the answer of the user to a question on the registration form: "I'm looking for a job" or "I'm looking for a job candidate" , the Contour Workflow should add the user to the 'jobseeker' member type or 'employer' member type.

    Is this possible with Contour?

    Thanks for your advice,

    Anthony

Please Sign in or register to post replies

Write your reply to:

Draft