• Resolved gteyespy

    (@gteyespy)


    Is there a way to create a custom required text field for a “sales” code that will identify the User as part of the “sales” group

    the logic behind this is for tracking sales which is loaded in a JS
    and need a unique way to upon registration to enter code “sales”.

    when “sales” code is registered it needs to load a unique JS for the user that registered with the “sales” promotion

    form sample:
    first name – last name – email – phone – promo code

    if promo code = XYZ123
    load JS file A

    if user is logged-in pages load with JS associated with promo code

    is this even capable with Ultimate Member?
    Is this a custom JS to load based on “promo code”?

    i could really use the help.

    SOS

    Thanks

    G

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @gteyespy

    Unfortunately, this requires customization on your end.
    Have you set up a custom post type or a new database table for the promo code? Or is the promo code static or just a few numbers of Promo code?

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter gteyespy

    (@gteyespy)

    Sorry for the late reply as I was on Holiday

    I think the best route would be a new table in the DB

    but i guess my question really is how do connect the form field (text) registration form as required and the db table to check if refferer code is valid.

    Then i can write a JS that says If user referral code equals A then load JS A. else equals B Load JS B . . etc.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @gteyespy

    You can create a new field with custom validation. Please see this doc explaining how to add a custom validation in PHP:
    https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-field

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved. ..Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter gteyespy

    (@gteyespy)

    i saw this and this is where i need help as i’m a PHP newb.

    where do I put in the parameter for the list i want to accept as the invite code.
    i.e dog, cat, bird, fish

    i’m sorry for the stupid qestion. i’m just new at this.

    /**
    * Validate field Invitation Code
    * @param string $key
    * @param attay $array
    * @param array $args
    */
    function um_custom_validate_invite( $key, $array, $args ) {
    if ( isset( $args[$key] ) && !preg_match(‘dog, cat, bird, fish’, $args[$key]) ) {
    UM()->form()->add_error( $key, __( ‘Please enter valid Invitation code.’, ‘ultimate-member’ ) );
    }
    }
    add_action( ‘um_custom_field_validation_invite’, ‘um_custom_validate_invite’, 30, 3 );`

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @gteyespy

    Sorry for the late response.

    You can try this code snippet:

    function um_custom_validate_invite( $key, $array, $args ) {
    if ( isset( $args[$key] ) && ! in_array( $args[$key],['dog','cat','bird','fish']) ) {
    UM()->form()->add_error( $key, __( ‘Please enter valid Invitation code.’, ‘ultimate-member’ ) );
    }
    }
    add_action( ‘um_custom_field_validation_invite’, ‘um_custom_validate_invite’, 30, 3 );

    The above code will check if the Invite code doesn’t match the input. If the input is not from the list(‘dog’,’cat’,’bird’,’fish’), it will throw Please enter valid Invitation code.

    Feel free to re-open this thread if there’s any question that may come up.

    Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘custom required field to load Javascript’ is closed to new replies.