Viewing 15 replies - 1 through 15 (of 15 total)
  • You could always get them separately and concatenate them.

    Thread Starter gransfor

    (@gransfor)

    i want output in once field separate by comma, for example : Joseph Campbell (name), 20 (old), New-York (city residences)

    For the attribute for that field you could add
    data-after::,
    Which would display a comma.
    However that only applies to the display of that field

    To put all the data in one field you could do something like…

    First create a field in pdp called ‘all_data’ or something like that.
    Then write some php. Download a php snippet plugin.

    <?php
    // Get all your required fields from WP
    $wp_user_id   = get_current_user_id();
    $current_user = wp_get_current_user();
    $wp_username  = $current_user->user_login;
    $wp_email     = $current_user->user_email;
    $wp_firstname = $current_user->user_firstname;
    $wp_lastname  = $current_user->user_lastname;
    
    $pdb_id=Participants_Db::get_record_id_by_term('username',$wp_username);
    
    //Now combine the data (Concatenate)
    $all_data=$wp_firstname.' '.$wp_lastname.', '.$wp_email.', '.$wp_user_id
    
    // This will display something like
    // Joseph Campbell, [email protected], 192
    
    //Now write the data to pdb
    data['all_data']=$all_data;
    $data = array();
    Participants_Db::write_participant($data,$pdb_id);
    ?>

    You can then display this on the front end using
    echo $all_data;

    There are a few small errors such as $data for the array.
    also you create the field in pdb ‘Manage Database Fields’

    Thread Starter gransfor

    (@gransfor)

    There are a few small errors such as $data for the array.

    what with her make?

    Thread Starter gransfor

    (@gransfor)

    and what stay in Default Value in field all_data?

    You don’t need anything in the default value. Leave it empty,

    Thread Starter gransfor

    (@gransfor)

    You can then display this on the front end using
    echo $all_data;

    I want output this field in total table (pdb-list), dont und how me using echo, also

    There are a few small errors such as $data for the array.

    what with her make?

    Code give error what there strange array

    You can output it using the shortcode

    [pdb_list fields=”all_data,other fields etc”]

    $data[‘all_data’]=$all_data;

    Thread Starter gransfor

    (@gransfor)

    $data[‘all_data’]=$all_data;

    Still a mistake

    This is correct.
    Where are you entering the code?
    It’s php and you either have to enter it in a snippet, plugin or child theme.

    If you use Wood Ad Snippets you can use the shortcodes

    [insert_php]

    $data = array();
    $data[‘all_data’]=$all_data;
    Participants_Db::write_participant($data,$user_id);

    php code goes here

    [/insert_php]

    Thread Starter gransfor

    (@gransfor)

    I download php snippet plugin

    Thread Starter gransfor

    (@gransfor)

    This is correct.

    you forgot to put ;

    • This reply was modified 5 years, 11 months ago by gransfor.
    Thread Starter gransfor

    (@gransfor)

    i make other way, write this code

    function stay_date_to_users() {
    global $wpdb;
    $current_user = wp_get_current_user();	
    $get_main_phone = $wpdb->get_var("SELECT phone FROM wp_participants_database WHERE id_private = '$current_user->id' "); // получает телефон компании
    $give_phone_to_users = $wpdb->query("UPDATE wp_users SET main_phone = '$get_main_phone' WHERE id = '$current_user->id'"); // даёт юзеру его телефон	
    $get_activity = $wpdb->get_var("SELECT activity FROM wp_participants_database WHERE id_private = '$current_user->id' "); // получает деятельность компании
    $give_activity = $wpdb->query("UPDATE wp_users SET activity = '$get_activity' WHERE id = '$current_user->id'"); // даёт юзеру его деятельность	
    $wpdb->query("UPDATE wp_users SET company = '$all_datas' WHERE id = '$current_user->id'"); // даёт юзеру его company	
    $wp_user_id   = get_current_user_id();
    $wp_username  = $current_user->user_login;
    $wp_email     = $current_user->user_email;
    $wp_main_phone = $current_user->main_phone;
    $wp_activity  = $current_user->activity;
    $wp_display_name  = $current_user->display_name;
    $all_datas = $wp_display_name.' '.$wp_main_phone.' '.$wp_email.' '.$wp_activity;	
    }
    stay_date_to_users();

    but ‘$wpdb->query(“UPDATE wp_users SET company = ‘$all_datas’ WHERE id = ‘$current_user->id'”);’ do not make update
    P.S all_data = current_user->company

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘get more data’ is closed to new replies.