This block is awsome, much thanks to the author. Problem is, i decided to use my custom actions mod to give the block its own page, action=join. Since i have moved it, when i attempt to submit the form it re-directs as it should and does not give any errors. BUT it doesnt make a new post, and it doesnt email me. When i had it set as a block, it did. So i figure it must be due to the custom actions mod, but im not sure what to modify or change. Could anyone shed some light?
NOTE: In the code the email is set to the default script email, but on the website it is set to mine. All the forum and article variables are correctly set.
global $sourcedir, $user_info, $context ;
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
//send the application by email?
$enable_email=true;
// email address of reqruitment staf member
$email_address='recruitement@your-clan.com';
//post the application on forum?
$enable_post=true;
//board id to which the application should be posted
$board_id=38;
//the id of the this article
$this_article_id = '6';
//article to be redirected when form is submitted
$thank_you_article_id = '6';
//END OF CONFIGURATION SECTION
$show_form= 'true';
if (isset($_POST['submitted'])) {
// Handle the form
// Check required fields
$enroll_errors = array(); //Initialize error array
// Check for a name
if (empty($_POST['real_name']) ){
$enroll_errors[] = 'You forgot to enter your name.';
}
// Check for an email
if (empty($_POST['email']) ){
$enroll_errors[] = 'You forgot to enter your email address.';
}
// Check for a player number
if (empty($_POST['ae_playerid']) ){
$enroll_errors[] = 'You forgot to enter your AE player ID.';
}
// Check for an age
if (empty($_POST['age']) ){
$enroll_errors[] = 'You forgot to enter your age.';
}
// Check for an gender
if (empty($_POST['gender']) ){
$enroll_errors[] = 'You forgot to enter your gender.';
}
// Check for an country
if (empty($_POST['country']) ){
$enroll_errors[] = 'You forgot to enter your country.';
}
// Check for an prev guild
if (empty($_POST['prev_guild']) ){
$enroll_errors[] = 'You forgot to enter previous guild. Enter NONE if needed.';
}
if (empty($enroll_errors)) { //Everything seems to be OK
$show_form='false';
// email an application
$subject = 'Enrollment Application';
$body = 'Enrollment application has been made by ' . $context['user']['name'] .
' from IP Address ' . $user_info['ip'] . '
Real Name: ' . $_POST['real_name'] . '
Email address: ' . $_POST['email'] . '
Player Number: ' . $_POST['ae_playerid'] . '
Age: ' . $_POST['age'] . '
Gender: ' . $_POST['gender'] . '
Country: ' . $_POST['country'] . '
Previous Guild: ' . $_POST['prev_guild'] . '
Why did you leave?: '.$_POST['prev_guildwhy'].'
Other information: ' . $_POST['other'];
$postbody = 'Enrollment application has been made by ' . $context['user']['name'] .'<br />
<table>
<tr><td>Real Name:<td></td><td> ' . $_POST['real_name'] . '</td></tr>
<tr><td>Email Address:<td></td><td> ' . $_POST['email'] . '</td></tr>
<tr><td>Player Number:<td></td><td> ' . $_POST['ae_playerid'] . '</td></tr>
<tr><td>Age:<td></td><td> ' . $_POST['age'] . '</td></tr>
<tr><td>Gender: <td></td><td>' . $_POST['gender'] . '</td></tr>
<tr><td>Country:<td></td><td> ' . $_POST['country'] . '</td></tr>
<tr><td>Previous Guild: <td></td><td> ' . $_POST['prev_guild'] . '</td></tr>
<tr><td>Why did you leave?: <td></td><td>' . $_POST['prev_guildwhy'] . '</td></tr>
<tr><td>Other information: <td></td><td> ' . $_POST['other']. '</td></tr>
</table>';
if ($enable_email)
mail($email_address, $subject, $body,"From: " . $_POST['email']);
//create new forum post with application
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . $context['user']['name'],
'body' => $postbody ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,
);
if ($enable_post)
createPost($msgOptions, $topicOptions, $posterOptions);
// Redirect to thank you page
header('Location: http://' . $_SERVER['HTTP_HOST'] .'/index.php?page=' . $thank_you_article_id);
} else {
// Redirect to error page
//header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php?page=' . $enroll_error_article_id );
echo '<h2 class="error">Error!</h2>';
echo '<p class="error">The following error(s) occured:<br />';
foreach ($enroll_errors as $msg) {
echo " - $msg<br />";
}
echo "<p>Please, correct all errors and try again.</p>" ;
}
}
//else { // Display the form
echo '
<form action="index.php?page=' . $this_article_id . '" method="post">
<INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
<TABLE class = "bordercolor" cellSpacing="1" cellPadding="1" width="95%" border="0">
<TR class ="windowbg">
<TD width = "200px">Name:</TD>
<TD><INPUT id="real_name" name="real_name" type="text" value ="';
if (isset($_POST['real_name'])) echo $_POST['real_name'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Email:</TD>
<TD><INPUT id="email" name="email" type="text" value ="';
if (isset($_POST['email'])) echo $_POST['email']; else echo $user_info['email'];
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Player ID:</TD>
<TD><INPUT id="aa_name" name="ae_playerid" type="text" value ="';
if (isset($_POST['ae_playerid'])) echo $_POST['ae_playerid'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Age:</TD>
<TD><INPUT id="age" name="age" type="text" value ="';
if (isset($_POST['age'])) echo $_POST['age'];
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Gender:
</TD>
<TD><SELECT id = "gender" name = "gender" style="WIDTH: 152px" value ="';
if (isset($_POST['gender'])) echo $_POST['gender'];
echo '" />
<OPTION value="No Answer" selected>Choose...</OPTION>
<OPTION value="M">Male</OPTION>
<OPTION value="F">Female</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Country:</TD>
<TD><INPUT id="location" name="country" type="text" value ="';
if (isset($_POST['country'])) echo $_POST['country'];
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Old Guild:</TD>
<TD><INPUT id="honor" name="prev_guild" type="text" value ="';
if (isset($_POST['prev_guild'])) echo $_POST['prev_guild'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Why did you leave?:</TD>
<TD><TEXTAREA id="prev_clans" name="prev_guildwhy" rows="4" cols="40" value ="';
if (isset($_POST['prev_guildwhy'])) echo $_POST['prev_guildwhy'];
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Other:</TD>
<TD><TEXTAREA id="other" name = "other" rows="4" cols="40" value ="';
if (isset($_POST['other'])) echo $_POST['other'];
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD colspan="2" align="center">
<INPUT type="submit" value="Submit">
<INPUT type="reset" value="Reset"></TD>
</TR>
</TABLE>
</form>
';
I have been toying with this and getting nowhere. No one has any ideas?
When you start using other mods in the mix there's not much support we can give you. I know zilch about custom action mod.
I have considered sending winrules a message, but i dont want to be one of those people that bothers others for help with their mod and another mod conflicting. Normally i can figure this stuff out when i really want too, but there must be something i am missing.