• Resolved uniak

    (@uniak)


    I use validation code `function wpuf_unique_kimlik_no_uyari( $error ) {
    if ( isset( $_POST[‘musteri_kimlik_numarasi’] ) ) {
    global $wpdb;
    $kimlikno = $_POST[‘musteri_kimlik_numarasi’];
    $product_id = $wpdb->get_var( $wpdb->prepare( “SELECT post_id FROM $wpdb->postmeta WHERE meta_key=’musteri_kimlik_numarasi’ AND meta_value=’%s’ LIMIT 1″, $kimlikno ) );
    if ( $product_id ) {
    return __( ‘This is an ERROR!’ );
    }
    }
    return ”;
    }
    add_filter( ‘wpuf_add_post_validate’, ‘wpuf_unique_kimlik_no_uyari’ );`

    user document page

    I want to add a value to return message like as:

    function wpuf_unique_kimlik_no_uyari( $error ) {
        if ( isset( $_POST['musteri_kimlik_numarasi'] ) ) {
            global $wpdb;   
            $kimlikno = $_POST['musteri_kimlik_numarasi'];
            $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='musteri_kimlik_numarasi' AND meta_value='%s' LIMIT 1", 
            $kimlikno ) );
            $sonucc =  get_field('musteri_danismani', $product_id);
            $tpt = the_field('calisan_adi_soyadi', $sonucc);
            $tpt2 = the_field('calisan_sirket_numarasi', $sonucc);
            if ( $product_id ) {
                return __( $tpt ."". $tpt2 );
            }
        }
        return '';
    }
    add_filter( 'wpuf_add_post_validate', 'wpuf_unique_kimlik_no_uyari' );

    But doesn’t return a message. How can i do this ? Can u help me ?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @uniak

    I’m really sorry for being late. My apologies.

    However, where did you get the the_field function? I mean, how did you manage it?

    We are not understanding the code you wrote. A few descriptions would be appreciable.

    Regards,

    Thread Starter uniak

    (@uniak)

    @thebengalboy Thanks for your reply 🙂

    I solved my problem.

    the_field is a advanced custom field code. You can look at: https://www.advancedcustomfields.com/resources/the_field/

    I solved my problem with this code type:

    
    function wpuf_unique_identity_no_error( $error ) {
        if ( isset( $_POST['customer_identity_no'] ) ) {
            global $wpdb;   
            $identityno = $_POST['customer_identity_no'];
            $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='customer_identity_no' AND meta_value='%s' LIMIT 1", $identityno ) );
          	$resultt =  get_field('customer_advisor', $product_id);
    		$tpt = get_field('customer_name_surname', 'user_'.$resultt);
    		$tpt2 = get_field('advisor_company_phone', 'user_'.$resultt);
    		$text1 = 'According to the information you have given your registration is in our system.<br/>Your advisor is: "<strong>';
    		$text2 = '</strong>" . You can contact him/her with <strong>';
    		$text3 = '</strong> phone number.';
    		$emp = 'According to the information you have given your registration is in our system.<br/> Your advisor has not yet been assigned. You can get information by calling <strong>+0 000 000 000</strong> phone number.';
    		if (( $product_id ) and (is_null($resultt))) {
    			return $emp;
    		}
    		elseif(( $product_id ) and ($resultt)) {
    			return $text1 . "" . $tpt . "" . $text2 . "" . $tpt2 . "" . $text3;
    		}
        }
        return '';
    }
    add_filter( 'wpuf_add_post_validate', 'wpuf_unique_identity_no_error' );
    

    Hello @uniak

    Thanks for sharing the solution with us. We’ll definitely refer to this, people who will face the issue similarly.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Validation Return Value Problem’ is closed to new replies.