I'm developing a new plugin for my mantis:
I would like to add the field 'Organisation' when I create a User (I do it as admin). This field had been added on db in the table mantis_user_table and I have values for it.
My problem is that I can not see the new tab when I create an user and I don't know where the problem is. It's my second plugin that I develop so I m not an expert
In MantisOrganisationUser.php
:
<?php
class MantisOrganisationUserPlugin extends MantisPlugin {
function register() {
$this->name = 'Organisation Plugin';
$this->description = 'Adds custom organization field to user registration.';
$this->version = '1.0';
$this->requires = array('MantisCore' => '2.24.0');
}
function hooks() {
return array(
'EVENT_USER_CREATE' => 'addOrganizationField',
);
}
function addOrganizationField($p_event, $p_user_id) {
# Get the organization value from the form submission or another source.
$organization_value = $_POST['organization']; # Replace with your form field name.
# Save the organization value to the user table.
user_set_field($p_user_id, 'organisation', $organization_value);
}
}
plugin_push_current("MantisOrganisationUserPlugin");
In manage_user_create_page.php
:
<?php
require_once( config_get( 'path_plugins' ) . 'your_plugin_name/core.php' );
layout_page_header( lang_get( 'user_create' ) );
# Add your Organization field here
?>
<div class="container">
<form action="<?php echo plugin_page( 'create_user' ); ?>" method="post">
<label for="username">Username:</label>
<input type="text" name="username" id="username" required><br>
<label for="realname">Real Name:</label>
<input type="text" name="realname" id="realname" required><br>
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" required><br>
<label for="access_level">Access Level:</label>
<select name="access_level" id="access_level">
<option value="25">Reporter</option>
<option value="55">Developer</option>
<option value="70">Manager</option>
<!-- Add other access levels as needed -->
</select><br>
<label for="enabled">Enabled:</label>
<input type="checkbox" name="enabled" id="enabled"><br>
<label for="protected">Protected:</label>
<input type="checkbox" name="protected" id="protected"><br>
<!-- Custom Organization field -->
<label for="organization">Organization:</label>
<input type="text" name="organization" id="organization"><br>
<input type="submit" value="Create User">
</form>
</div>
<?php
layout_page_footer();
I want to see the new tab on create user page, but it doesn't appear.
The plugin had been installed in a correct way.