• Resolved hurab

    (@hurab)


    Hi i have followed every step of the encoding as you have suggested and have changed few field
    add_action( ‘wp_ajax_nopriv_get_user_information’,’smartform_ext_get_user_information’);
    add_action( ‘wp_ajax_get_user_information’,’smartform_ext_get_user_information’);

    function smartform_ext_get_user_information(){
    $current_user = wp_get_current_user();
    if($current_user==false)
    return “{}”;

    echo json_encode(array(
    “name”=>$current_user->user_firstname. ‘ ‘. $current_user->user_lastname,
    “order id”=>$current_user->user_order_id,
    “products”=>$current_user->user_products
    ));
    die();

    }
    but when i enter the function Remote.Post(ajaxurl,{“action”: “get_user_information”}).name for name it gives me error remote is not defined please guide where i am doing wrong
    much thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author EDGARROJAS

    (@edgarrojas)

    could you send me a link to your form please?

    Thread Starter hurab

    (@hurab)

    I use the below code which you provided but with some ammendments i changed the email with order number and products.

    add_action( ‘wp_ajax_nopriv_get_user_information’,’smartform_ext_get_user_information’);
    add_action( ‘wp_ajax_get_user_information’,’smartform_ext_get_user_information’);

    function smartform_ext_get_user_information(){
    $current_user = wp_get_current_user();
    if($current_user==false)
    return “{}”;

    echo json_encode(array(
    “name”=>$current_user->user_firstname. ‘ ‘. $current_user->user_lastname,
    “ordernumber”=>$current_user->order_number,
    “productName”=>$current_user->product_name
    ));
    die();

    }

    this is the link of the form https://www.greencotton.my/post_type=smartforms_preview&p=11213&sfpreview=true

    2. please guide why the two lines are appearing as the header on the form

    Much Thanks

    Plugin Author EDGARROJAS

    (@edgarrojas)

    Hello, i checked your link but i got ‘page not found’ do i have the right link? seems like you send me the preview url which is actually not public. You would need to add the form to a page/post and send me the link to it.

    Regards!

    Thread Starter hurab

    (@hurab)

    oops sorry

    https://www.greencotton.my/returrn/

    now i saw its only that name can be autofilled defaulted but the other cannot
    Please guide

    Much Thanks

    Plugin Author EDGARROJAS

    (@edgarrojas)

    Does that form has that remote thing? I checked the form but couldn’t find it.

    Thread Starter hurab

    (@hurab)

    hi if you want so i can provide you the login so you can check

    Thread Starter hurab

    (@hurab)

    actually what i have done is that on my clients account dashboard i have inserted the button return order and when they press the button the form should appear autofilling their product name and order number. they just have to write Reason of return
    i changed your code wording only
    add_action( ‘wp_ajax_nopriv_get_user_information’,’smartform_ext_get_user_information’);
    add_action( ‘wp_ajax_get_user_information’,’smartform_ext_get_user_information’);

    function smartform_ext_get_user_information(){
    $current_user = wp_get_current_user();
    if($current_user==false)
    return “{}”;

    echo json_encode(array(
    “name”=>$current_user->user_firstname. ‘ ‘. $current_user->user_lastname,
    “ordernumber”=>$current_user->order_number,
    “productName”=>$current_user->product_name
    ));
    die();

    }
    is there something i am doing wrong please help me to get the autofilled order number

    Plugin Author EDGARROJAS

    (@edgarrojas)

    Hello!

    Sorry for the delay, just checked again and it seems to be working. In my case it doesn’t fill the fields because i am not logged in but the service returns the data properly:

    {“name”:” “,”ordernumber”:false,”productName”:false}

    The formula displays the data ‘name’ (which in this case is an empty string).

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘error for remote validation’ is closed to new replies.