Pragmatism in code

If you would like to automatically apply membership levels to new members, then this mod is for you.

This can also be useful when wanting to differentiate between different member groups - ie - making all female members of a female only member group. Both methods are shown below.

in profile_activate.php


//Promotional membership
if ( getParam('enable_promotion_membership') == 'on' )
$memership_days = getParam('promotion_membership_days');
setMembership( $p_arr['Couple'], MEMBERSHIP_ID_PROMOTION, $memership_days, true );

add underneath

setMembership( $p_arr['ID'], MEMBERSHIP_GROUP_ID, 0, true );

Change MEMBERSHIP_GROUP_ID to the ID of the group you want members to automatically become a member of. You can get this by looking in the sys_acl_levels database table.

If you wish to target a specific type of member - for example females, then you need to determine which type the new member belongs to. In this case instead of the code above, use the following code instead.

if ($p_arr['Sex'] == 'female') {
setMembership( $p_arr['ID'], FEMALE_MEMBERSHIP_ID, 0, true )

Simply change $p_arr['Sex'] to whatever profile field you wish to check for, this also includes any custom profile fields that you have added.