Automatically assigning Author role to new registrations

I want to enable checkbox by default when any new user register our ojs site

The template that controls this display is templates/user/register.tpl, particularly:

The option is set by $registerAsAuthor. This could be initially defaulted similar to $registerAsReader in the Form Controller:

what code i have to write here for enable check box. I see this code but not understand

Do you have anyone with PHP experience? I recommend against making changes to the codebase unless you do.

The setData() function assigns a data variable for the form, setting in Smarty a variable named as the first parameter, with a value of the second parameter. Your change will look like $this->setData('registerAsAuthor', 1);

1 Like

thanks for this its great it works for me

Alternatively, users might modify the register.tpl template to ignore the default setting:

{if $allowRegAuthor || $allowRegAuthor === null}<input type="checkbox" name="registerAsAuthor" id="registerAsAuthor" value="1" checked="checked" /> <label for="registerAsAuthor">{translate key="user.role.author"}</label>: {translate key="user.register.authorDescription"}<br />{/if}

I think modifying a template is more the way modifications should be done. On the other hand it might be considered as bad style to ignore the settings from the controller. Best solution would be to make the settings configurable for users.

thanks for the reply isir please help me my all other mail function work properly. but new resgistration and submission acknowledgement mail not worrking \i am using ojs 2.4.7

First go to classes/user/form/RegistrstionForm.inc.php, then add " $this->setData(‘registerAsAuthor’, 1);" line of code in initData() function like follows:

function initData() {
$this->setData(‘registerAsReader’, 1);
// you can add the code here
$this->setData(‘existingUser’, $this->existingUser);
$this->setData(‘userLocales’, array());
$this->setData(‘sendPassword’, 0);
}

Thank you very much. @ctgraham Thank you. I don’t have any experiences of making php but i want to try fixing this and i am wondering if you can teach me where to open this. I guess that i would love to try it myself. Please help.

I think @habtamu’s post has a pretty clear description of where to find the file and how to add the code.

If you give it a try and run into trouble, feel free to post your changes here, using three backticks to surround any code, like:

code here

It looks like there are plenty of folks on this thread who are interested and have been willing to help!