I have an article set up that I need conditionals on but I dont know how to do it.
the current code is:
<p>To obtain the AYC racing password please complete the <a href="http://vsk-ayc.totalh.com/index.php?page=70">Racing Fleet Application</a>.</p>
What I need to do is this:
if membergoup = Racing Fleet Member (Group #13)
then display this: The password for AYC events is xlr8 (lower case)
All others display the attached code
If anyone can help me with this, I would appreciate it.
TimUSA
Try this:
global $scripturl, $user_info;
if (in_array(13, $user_info['groups'])
{
echo '<p>The password for AYC events is <b>xlr8</b> (lowercase)</p>';
}
else
{
echo '<p>To obtain the AYC racing password please complete the <a href="', $scripturl, '?page=70">Racing Fleet Application</a>.</p>';
}
This has to be in a php article (you may want to delete the one you have and create a new article using php).
Close I get this:
Sorry. Missing a closing parenthesis:
global $scripturl, $user_info;
if (in_array(13, $user_info['groups']))
{
echo '<p>The password for AYC events is <b>xlr8</b> (lowercase)</p>';
}
else
{
echo '<p>To obtain the AYC racing password please complete the <a href="', $scripturl, '?page=70">Racing Fleet Application</a>.</p>';
}
This worked thanks! :up:
if i change this code:
if (in_array(1, $user_info['groups']))
to include multiple groups:
if (in_array(1, 13, $user_info['groups']))
the code sends me to the "else" message
Right. That function checks if the first argument is in the array which is the second argument.
You could do an OR for the two different values:
if (in_array(1, $user_info['groups']) || in_array(13, $user_info['groups']))
Or you can try the array_intersect() function and check for non-zero count:
if (count(array_intersect(array(1,13), $user_info['groups'])))
The second line worked fine. All done. Thanks for your help