Registration Plugin

Hello fellow Omeka users !

I am trying to develop a new plugin allowing unregistred users to fill a form in order to request a registration. The validation will then be performed by one of the administrator (aka creating a new user). In this form they would indicate (among other things) email, name, login name and the role they desire.
I have looked up the Guest user plugin but i think it is kind of to much for what i want to do.

So, here is my first question : do you think that i should modify the guest user plugin or creat a new one (which i have started).
Also i want to put the registration link on the bottom of the login page. But i have trouble calling my plugin function (and php files), because it happend on the admin side of the website and the user is not actually logged in. I am systematically redirected on the login page and the form is not processed.

I hope my question is clear enought (english is obviously not my native language), and thank you in advance for all the help you could provide me !

I would definitely start with the Guest User plugin, since the basics of what you need are already there. If nothing else, just copy the needed parts from there into your plugin.

The login page doesn’t have a hook or filter for adding the link, so your only option there is to directly modify the view file.

Thank you for your answer.

By view file, do you mean the login.php file in the admin theme ? Because this is what i did : i add a ‘register’ button wich call a jQuery script creating a form, but when i try to send the form it automatically redirect to the login page without executing the file supposed to be called by the post.

Here is a sample of my code :

jQuery("#creatuser").click(function() {
	jQuery('#login-form').remove();
	jQuery('#forgotpassword').remove();
	jQuery('#creatuser').remove();
	var form = jQuery("<form/>", 
            { onsubmit:'requestUser(); return false;',
              enctype:'application/x-www-form-urlencoded',
              methode: 'post'}
    );
	form.append( 
	    jQuery("<input>", 
	        { type:'text', 
	          placeholder:'Nom', 
	          name:'name1' }
	    )
	);
	form.append( 
	    jQuery("<input>", 
	        { type:'text', 
	          placeholder:'Prénom', 
	          name:'name2' }
	    )
	);
	_some other input field_
	form.append( 
	    jQuery("<input>", 
	        { type:'submit', 
	          value:'Valider' }
	    )
	);
	console.log(form);
	jQuery('.eight.columns.alpha.offset-by-one').append(form);
});

function requestUser(){
	jQuery.ajax({
		url : 'request-user.php',
		type : 'POST',
		data : '',
		dataType : 'html'

	});
}

Ah. I see what you mean. I suspect that Omeka’s permissions system is intercepting the AJAX request, seeing the effort to get to the admin side by a non-user, and doing its usual redirect.

You’ll probably have to just directly add the form to the login.php page (and keep a note of your changes to redo them with subsequent Omeka upgrades, which will overwrite them).

The other alternative is alter the ACL, and maybe intercept the request the same way GuestUser does it.

Hello ! It is me again …

My plugin is almost done, i can now successfully add registration request, and the admin can then validate them and assign role to new user.

I am just trying to add a reCaptcha to my registration form, but unfortunatelly i have trouble with the validation. I got the following error :

Uncaught Error: Call to a member function isValid() on string

I used the same method to add the captcha than the one used in the SimpleContactForm Plugin, here are samples of my code concerning the reCaptcha :

CONTROLLER :
protected function _setupCaptcha(){
        return Omeka_Captcha::getCaptcha();
}

public function registerAction(){
       ...
        $captchaObj = $this->_setupCaptcha();
        if ($captchaObj) {
            $captcha = $captchaObj->render(new Zend_View);
        } else {
            $captcha = '';
        }
        $this->view->assign(compact('captcha'));
        ...
        if ($captcha && !$captcha->isValid('foo', $_POST)) {
            echo "<p id='captcha' class='error'> Vérification incorrecte, veuillez réessayer </p>";
            $error = true;
        }

REGISTER.PHP :
...
<?php if ($captcha): ?>
    <div class="field">
        <div id="captcha-label" class="two columns alpha">
            <label for="captcha" class="required">Vérification</label>
        </div>
	<div class="inputs five columns omega">
	    <p class="explanation">Êtes-vous un robot ?</p>
	        <?php echo $captcha; ?>
	</div>
    </div>
<?php endif; ?>
...

Do you have any ideas about the source of the problem ?

Hi, if you still need help, here it is…
As the error says, you’re trying to call method isValid() on string. $captcha is string, because you rendered captcha and stored it into this variable few lines earlier. What you want must be done against the object, in your case $captchaObj.

if ($captchaObj && !$captchaObj->isValid('foo', $_POST)) {

Goog luck!

I hate it when the solution is so obvious but i could not figure it out …

Thank you anyway ! All is running smoothly now.

Is there a plug in like this but also accepts payments from viewers? Like a paid membership to view the private collection?

I am not aware of anything like that. Also, if i may say so, i do not think that Omeka is build for (or in the spirit of) any paying use.

I don’t know of anything like that either, but – speaking solely for myself and not for Omeka or RRCHNM – I would have no objection to that, or even a shopping cart plugin. Indeed Omeka isn’t built with that in mind, but I can imagine a private art gallery using Omeka, for example. Paid access or a shopping cart would make a lot of sense in that situation. After all, we’ve all gotta keep funding ourselves somehow! :slight_smile:

This topic was automatically closed after 250 days. New replies are no longer allowed.