latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Get role on signup

Home Forums Community Forum Get role on signup

This topic contains 1 reply, has 2 voices. Last updated by  David Welch 4 years, 6 months ago.

Topic Author Topic
Posted: Monday Jun 18th, 2012 at 8:05 pm #16805

Hi,

I’m trying to have different roles auto-join certain groups in BP.

I have this code but it’s not working, I think because the user isn’t logged in yet. How do I get the user’s role during the registration process but before they have logged in?

if( !$user_id ) return false;
$roles = get_user_field (“s2member_access_role”, $user_id);
if ($roles != ‘s2member_level2’) {
groups_accept_invite( $user_id, 2 );
}else{
groups_accept_invite( $user_id, 3 );
}
}
add_action( ‘bp_core_activated_user’, ‘automatic_group_membership’ );

Thanks!

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Monday Jun 18th, 2012 at 10:36 pm #16817
David Welch
Username: dwbiz05

I believe you want to hook into the s2member registration hook(s).

Maybe this one?

<?php
add_action('ws_plugin__s2member_after_configure_user_registration','automatic_group_membership');

function automatic_group_membership($vars=array()){

	//print_r($vars); //uncomment this line to see a print out of all the available variables to use in the code below.
	
	if( !$user_id ){
		return false;
	}
	else {
		$roles = get_user_field (“s2member_access_role”, $user_id);
		
		if ($roles != ‘s2member_level2′) {
			groups_accept_invite( $user_id, 2 );
		}
		else {
			groups_accept_invite( $user_id, 3 );
		}
	}
	
	exit();
}
?>

Hope that helps,

Dave

Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.