Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Community builder and ​​​​GroupJive groups.

Community builder and ​​​​GroupJive groups.

Hi!

I'm using Joomla 1.5 with Community builder​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ and Groupjive (allows users to create their own groups).

I'm also using an affiliate marketing tool called Amigos.

When a user logs in, I would like to be able to determine if he is a member of a Groupjive group.

If he is a member of a group (or groups), I would like him to be redirected to the front page, but with an Amigos tag, so the group owner would get a percentage if the user ended up buying something.

My database is called Joomla_1 and the table which holds the relevant GroupJive information is called #__gj_users. This table contains the coloums: id, id_user, username, id_group, date and status.



So the code should look something like this:

if ($user->id>0) {

Get ahold of the userid.

Search Database table (#__gj_users) and retrieve records corresponding to the userid (id_group and id) */"id" is an auto incremented value created by the database/*

if there are several ids (user is part of more than one group), select the lowest value (as that is the first one he or she joined),

return the corresponding id_group number.

If (id_group == 4);

header ("Loaction: http://localhost:8888/joomla_1/?amigosid=1); */going to the frontpage, but with the affilate tag. */

if (id_group == 5);

header ("Loaction: http://localhost:8888/joomla_1/?amigosid=2); */BTW: safari gives me an error when redirecting to an internal page "too many redirects..." is there any way around that?*/

Come on. WORK!

Please...?

}



I´m just kidding, I have no idea what the code should look like, as I don´t know the first thing about php or programming in general for that matter.

If anyone could point me in the right direction, I would greatly appreciate it.

Julian

apollo123
Beginner Modder
ranks
useravatar
Offline
17 Posts
Administrator has disabled public posting

Re: Community builder and ​​​​GroupJive groups.

OK. So I made an effort to learn some php, and this is what I came up with.

if ( $user->id < 0 );
$query="SELECT * FROM #__gj_users WHERE id_user= $user->id "; //searches the gj_users table using the users id as a parameter
$result=mysql_query($query);

mysql_close();

$group=mysql_result($result,$i,"id_group"); //the group id of the first group the user joined

if ($group == 4){
//echo ("You will now be redirected to the frontpage with the appropriate amigosid tag (1)");
$app = &JFactory::getApplication();
$app->redirect( JRoute::_('?amigosid=1' ) );
}if ($group == 5){
//echo ("You will now be redirected to the frontpage with the appropriate amigosid tag (2)");
$app = &JFactory::getApplication();
$app->redirect( JRoute::_('?amigosid=2' ) );
}

This pretty much works the way I would want it to, except the redirect does not work if the page is not external.
I have tried using  header ("Location: http://thepage"), but it does not make any difference.

Does the page need to be hosted in order for this to work (I´m currently just testing using localhost), or am I doing something else wrong??

Any help would be greatly appreciated.

apollo123
Beginner Modder
ranks
useravatar
Offline
17 Posts
Administrator has disabled public posting

Re: Community builder and ​​​​GroupJive groups.

ok, just looking at this now:

1 - your first line should be "> 0" not "< 0"  but I suspect you knew that

2 - the JRoute thing is the issue I think. Can you tell me what you're actually trying to redirect to? Are you trying to redirect to the current page, or to the front page of the site? If to the front page, there's not much need for JRoute - just redirect directly to "http://www.mysite.com/?amigosid=1" or whatever.

e.g. $app->redirect( "http://www.mysite.com/?amigosid=1" );


Now, if you are getting redirect loops, then you also need to check that you're *not* going to do a second redirect. You will know if you already did a redirect, because the "amigosid" will already be set. So try this code just before the code you already have:

if ( JRequest::getVar("amigosid") != "" ) return;

That checks to see if amigosid was specified in the URL already, then bails out if it finds it.

Now, the last problem is about where you actually want this code to run. Should it get run for every page on your site, or just on a particular page? The problem is that if you run it on every page then it's *always* going to redirect people back to the front page again.

You said in the 1st post that you want this to get run when people log in, only. So perhaps you should make an article page that's going to be your landing page when people log in. Assign this module only to that page. Then people aren't going to hit this module and get redirected unless it's as a result of logging in - just where you want it!

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Community builder and ​​​​GroupJive groups.

See, now that´s why they call you the metamodguy smile
It now appears to work flawlessly.
I put this line in (as you suggested) : if ( JRequest::getVar("amigosid") != "" ) return; -and that seemed to solve everything.
Yes, a landing page...not a bad idea..I guess people eventually would grow tired of the frontpage smile

I will get this page online soon, and then I will be able to find out if the affiliate tracking is actually working as it is supposed to.
I will reply to this post in any case, just to let you know.

I don´t believe I actually need any of the commercial software you are selling, but if my page ever generates some revenue I will buy a copy to show my support nonetheless.
Great module. Amazing support!
Thanks Stephen!

apollo123
Beginner Modder
ranks
useravatar
Offline
17 Posts
Administrator has disabled public posting

Re: Community builder and ​​​​GroupJive groups.

Hey, glad it worked smile This sort of awkward problem is something that MetaMod excels at!

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10746
Newest User:
victor1234
Members Online:
0
Guests Online:
177

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked