• Resolved mintpirate

    (@mintpirate)


    Thanks in advance for any assistance. We have approximately 1000 consultants who will ultimately use our new site for new training and reference materials.

    Question: Rather than manually add these users manually, I want them to do the work, set their passwords, etc. Is it possible to publish a voucher and then not allow registration to complete unless you have that voucher?

    I know there are a variety of plug ins for site access. I would rather limit the number of total potential conflicts and just use LifterLMS.

    Any advice is appreciated.

    Thank you.

    https://www.ads-software.com/plugins/lifterlms/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hey mintpirate,

    We do not currently have a feature that would allow you to *only* register for a course using a voucher. However, you could hook into our registration form and make the voucher a required field fairly easily.

    You could tap into our action lifterlms_new_user_registration” which runs prior to registering a user, determine if they’ve submitted a voucher, and return an error if they haven’t:

    <?php
    add_action( 'lifterlms_new_user_registration', function() {
    
        if ( ! isset( $_POST['llms_voucher_code'] ) || empty( $_POST['llms_voucher_code'] ) ) {
    
              llms_add_notice( 'Voucher is required', 'error' );
    
        }
    
    });

    Something along those lines should get you going.

    Please take a look at that and let me know if you require any additional assistance.

    Take care,

    Hi,
    I’m interested in installing this feature. Please, where is the user form to insert this code?
    Thank you.

    Hey Projete,

    Apologies for lack of clarity above.

    I’d recommend adding this snippet to your theme or child theme’s functions.php or, even better, creating yourself a small custom plugin. You want to be careful to add it in a place that will not be lost when updating your theme. Many theme’s will recommend a child theme for functions like this so that you can safely update the theme without losing customizations. A custom plugin is ideal as well for the same reason.

    The action itself will be run immediately prior to any additional validation that runs when a user submits the LifterLMS User Registration form.

    I would strongly advise against adding this code directly to LifterLMS or modifying the form or handler function that calls this action. This action exists so you don’t have to modify the code itself!

    Hope that helps,

    Hi,
    Thank you for your patience and support.
    I inserted the code in my child theme. It worked very well requesting a voucher for registration in a course with the link exemplo.com/register-now/?product=20.
    How can I prevent the member register in “exemplo.com/register-now” page without voucher?

    Thanks again.

    Hey projete,

    the code snippet provided should be working for both of these registration forms — is this not the case? It might need to be tweaked a bit. Please retry and let me know if I’m mistaken and I will try a different solution if that’s not working.

    Take care,

    Hi, Thomas.
    I made a mistake on my test. Although I have a message that vocher is required it is possible to register a member in both situations without entering the codes.
    We need a different solution.

    Thank you very much.

    add_filter( 'lifterlms_user_registration_errors', function( $errors ) {
    
    	// if the voucher is not submitted or is empty
    	if( ! isset( $_POST['llms_voucher_code'] ) || empty( $_POST['llms_voucher_code'] ) ) {
    
    		// need to be sure $errors object is a WP_Error instance
    		if ( ! is_wp_error( $errors ) ) {
    
    			$errors = new WP_Error();
    
    		}
    
    		// add your error
    		// parameters are:
    		// 	voucher code (not really needed or used but required)
    		//  error message
    		//  data to pass (again not really needed)
    		$errors->add( 'voucher-required', __( 'You must use a voucher', 'mytextdomain' ), array() );
    
    	}
    
    	return $errors;
    
    } );

    Please have another shot with this snippet,

    Thread Starter mintpirate

    (@mintpirate)

    Thank you. This works.

    It would be nice if there was some advanced user management / restriction tools incorporated in the plugin proper, it would widen implementation options.

    Thank you for your help. It is much appreciated.

    Hey Mint,

    I agree re: your suggestion and we’ve discussed and already roadmapped some features. I would urge you to visit LifterLMS.com/contact and submit any specific feature requests you might have. We’ll filter through them and drop them into our public feature request board where you can vote on any features you might want us to see. I suggest you take a look today and place your votes.

    https://trello.com/b/egC72ZZS/lifterlms-feature-requests-public-voting

    Take care,

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Restriction of Registration’ is closed to new replies.