• I am somewhat of a newbee to wordpress and found the Shortcodes Actions And Filters Plugin to be the ideal plugin to check if someone has already registered using the same email.

    I found code that will verify if an e-mail address has been used already.

    I am not sure what to put in for $formname = ‘xxxx’ do I put in the url of the form ((https://tp4fe.org/?page_id=3859)), or do I put the short code of the contact form ([contact-form-7 id=”3874″ title=”Request to Raise Funds Form”]), or do I put the name of the form which includes spaces (Request to Raise Funds Form).

    Additionally, there is a field named Execute only for. I am not sure what that is used for. A link to a tutorial or documentation would help this newbee greatly. Does that exist?

    Please provide info.

    the code is as follows:

    **
    * @param $formName string
    * @param $fieldName string
    * @param $fieldValue string
    * @return bool
    */
    function is_already_submitted($formName, $fieldName, $fieldValue) {
    require_once(ABSPATH . ‘wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php’);
    $exp = new CFDBFormIterator();
    $atts = array();
    $atts[‘show’] = $fieldName;
    $atts[‘filter’] = “$fieldName=$fieldValue”;
    $atts[‘unbuffered’] = ‘true’;
    $exp->export($formName, $atts);
    $found = false;
    while ($row = $exp->nextRow()) {
    $found = true;
    }
    return $found;
    }

    /**
    * @param $result WPCF7_Validation
    * @param $tag array
    * @return WPCF7_Validation
    */
    function my_validate_email($result, $tag) {

    $formName = ’email_form’; // Change to name of the form containing this field

    $fieldName = ’email_123′; // Change to your form’s unique field name
    $errorMessage = ‘Email has already been submitted’; // Change to your error message
    $name = $tag[‘name’];
    if ($name == $fieldName) {
    if (is_already_submitted($formName, $fieldName, $_POST[$name])) {
    $result->invalidate($tag, $errorMessage);
    }
    }
    return $result;
    }

    // use the next line if your field is a **required email** field on your form
    add_filter(‘wpcf7_validate_email*’, ‘my_validate_email’, 10, 2);
    // use the next line if your field is an **email** field not required on your form
    add_filter(‘wpcf7_validate_email’, ‘my_validate_email’, 10, 2);

    // use the next line if your field is a **required text** field
    add_filter(‘wpcf7_validate_text*’, ‘my_validate_email’, 10, 2);
    // use the next line if your field is a **text** field field not required on your form
    add_filter(‘wpcf7_validate_text’, ‘my_validate_email’, 10, 2);

Viewing 1 replies (of 1 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    This is more of a question about the CFDB plugin on this help page: https://cfdbplugin.com/?page_id=904

    Following that page, you copy the PHP code and paste it as a new code element in Shortcodes, Actions and Filters plugin. You do NOT have the shortcode box checked. You are adding filter functions, not a new shortcode.

    You can ignore “Execute only for”. If you look at its drop-down, it list all the roles in your WP system. So that code would only be executed for users with the role selected there.

Viewing 1 replies (of 1 total)
  • The topic ‘Shortcodes Actions And Filters Plugin Need tutorial or instructions’ is closed to new replies.