Customizing SMF > Mod Requests
URL to join a Membergroup from anywhere in the forum.
Wilo:
Hi,
SMF 2.0.2
Simple Portal
Is there, or can a Mod be developed whereby a specific membergroup can be joined or left from a link. So the member could click Join Group to join a membergroup with out having to goto their profile/group membership page.
For Example, I have a page (using Simple Portal) containing information about a group (membergroup). On that page a button would exist called join group. The member presses Join Group and the member now can access boards and permissions managed by that particular membergroup. The button would then change to Leave group to leave the membergroup.
Many thanks,
W
Yoshi:
Hi there,
Is PHP supported in Simple Portal pages?
Wilo:
Yes. You can add a PHP block of code anywhere.
Yoshi:
--- Quote from: Wilo on March 27, 2012, 10:04:14 AM ---Yes. You can add a PHP block of code anywhere.
--- End quote ---
Then that's great :)
Add this as PHP block:
--- Code: ---<?php
global $user_info;
if (!in_array(number_of_your_membergroup, $user_info['groups']))
{
echo '<a href="http://url.to.your/forum/index.php?action=profile;save;u=' . $user_info['id'] . ';area=groupmembership;gid=number_of_your_membergroup">Join this group!</a>';
}
else
{
echo '<a href="http://url.to.your/forum/index.php?action=profile;save;u=' . $user_info['id'] . ';area=groupmembership;gid=number_of_your_membergroup">Leave this group!</a>';
}
?>
--- End code ---
Replace "number_of_your_membergroup" with the ID of the membergroup in question.
Wilo:
Hi, Thankyou very much for your time.
I've added the code however I get the following
Whoops!
Session verification failed. Please try logging out and back in again, and then try again.
Here's the code i'm entering.
<?php
global $user_info;
if (!in_array(20, $user_info['groups']))
{
echo '<a href="//test_server/index.php?action=profile;save;u=' . $user_info['id'] . ';area=groupmembership;gid=20">Join this group!</a>';
}
else
{
echo '<a href="//test_server/index.php?action=profile;save;u=' . $user_info['id'] . ';area=groupmembership;gid=20">Leave this group!</a>';
}
?>
Navigation
[0] Message Index
[#] Next page
Go to full version