• Resolved Anonymous User 14388610

    (@anonymized-14388610)


    Hello,

    I just wondered if there was any option to add a condition that has to case-insensitively match a certain string when registering. I want to use it as a honeypot where users have to enter a given string because our website has suffered multiple bot attacks. The option “Custom Action” was referring to the action hooks in the documentary but unfortunately I couldn’t work out how to do it from the documentation.

    Any help is greatly appreciated, thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support mansurahamed

    (@mansurahamed)

    Hi @fliwatt,

    Add following code in your child theme’s functions.php file which should do the trick. Replace all instances of custom_field_metakey with your actual text fields metakey & change ‘Wrong value provided’ error message to anything you want. Change the String “hope” to your actual string to check.

    function um_custom_validate_customfield( $args ) {
    if ( isset( $args['custom_field_metakey'] ) ) {
    $mystring = "hope";
    if (  strcasecmp($args['custom_field_metakey'],$mystring) != 0) {
    $message = sprintf( __( 'Wrong value provided', 'ultimate-member' ), $domain );
    UM()->form()->add_error( 'custom_field_metakey', $message );
    }
    }
    }
    add_action( 'um_submit_form_errors_hook__registration', 'um_custom_validate_customfield', 99 );

    Thanks.

    Thread Starter Anonymous User 14388610

    (@anonymized-14388610)

    Thank you so much for providing me with your custom code! This is exactly what I needed and works beautifully, just one little thing, I get the PHP Warning:

    Warning: Undefined variable $domain in /var/www/[…]/wp-content/themes/freielasten/functions.php on line 227

    Everything is working fine though.

    Plugin Support mansurahamed

    (@mansurahamed)

    Hi @fliwatt,

    In the code replace $domain with $mystring , that should solve your issue. It was a typing mistake.

    Thanks.

    Thread Starter Anonymous User 14388610

    (@anonymized-14388610)

    Thank you very much, you are awesome!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @fliwatt

    Thanks for letting us know how it resolved the issue.

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to create quiz?’ is closed to new replies.