• Resolved mgeorg45

    (@mgeorg45)


    Hello,

    I managed to block different domains that I do not want to be used for user registration, although when a user tries to register using one of them([email protected]), upon clicking the register button the page just reloads without displaying the appropriate message (We don’t accept registrtations from that domain).

    Is there a way to fix this?

    Thanks in advance,
    Marios

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @mgeorg45

    Please try following code snippet to block and show message for blocked domains:

    add_action( 'um_add_error_on_form_submit_validation', function( $array, $key, $args ){
        $blocked_domains = ['gmail.com','yahoo.com','aol.com'];
        if( 'user_email' == $key ){
            $email_arr = explode('@',$args[$key]);
            if( in_array( $email_arr[1], $blocked_domains)){
                UM()->form()->add_error( $key, __( 'We do not accept email from this domain.', 'ultimate-member' ) );
            }
        }
    
    },2,3 );

    You will have to replace domains in $blocked_domains = [‘gmail.com’,’yahoo.com’,’aol.com’]; as per your requirement.

    Thread Starter mgeorg45

    (@mgeorg45)

    Hello @aswingiri,

    Thanks for the reply.
    I tested the code in my functions.php file but I get the same outcome. Still, no message just refresh the page.

    Update:
    I had to remove the blocked domains from the WP Admin > Ultimate Member > Settings > Access > Other > Blocked Email Addresses.

    Now everything works fine!
    Again thanks for the reply.

    • This reply was modified 2 years, 8 months ago by mgeorg45.
    • This reply was modified 2 years, 8 months ago by mgeorg45.

    @mgeorg45

    What is the URL when you expect to get the error message?
    Do you get a value of the err= ?

    Have you used the UM Setting “Blocked Email Addresses (Enter one email per line)”?
    Please post here in the Forum an example of an email address in this list which fails the error message.

    This is a basic UM core function which should work without adding a code snippet.

    • This reply was modified 2 years, 8 months ago by missveronica.
    Thread Starter mgeorg45

    (@mgeorg45)

    Hello @missveronicatv,

    Yes I did use the UM Setting Blocked Email Addresses (Enter one email per line).
    The problem is that when a user registered with an email from a blocked domain, the page just refreshes to the homepage without an error message.
    After adding the above snippet and removing the domains from UM Setting Blocked Email Addresses, everything works perfectly.

    Marios

    @mgeorg45

    I’m interested to find out why the basic UM function of email blocking did not work as expected.

    What was the format you used for blocking an email domain?

    gmail.com
    *gmail.com
    *@gmail.com

    The tooltip for the email block setting is:

    To block an entire domain, use something like *@domain.com

    Thread Starter mgeorg45

    (@mgeorg45)

    Yes I did use *@domain.com

    The problem was that that the registration was blocked but I wasn’t shown an error message. I just wanted to show an error message to the user to let him know why the registration failed.

    @mgeorg45

    I tried to do registrations with gmail.com email addresses with blocking set to *@gmail.com

    I got the error message on top of the Registration form as expected:

    We do not accept registrations from that domain.

    I can not recreate the error.

    Thread Starter mgeorg45

    (@mgeorg45)

    Hello @missveronicatv,

    As I said above, the problem is solved now.
    That is the reason you can’t duplicate the error.

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know how you’ve resolved the issue.

    Thanks @missveronicatv, for extending help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Message not displayed after blocked email registration’ is closed to new replies.