get more data
-
Hi, i want get current_user->display_name and user_email and id and etc in once field
-
You could always get them separately and concatenate them.
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 fieldTo 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, jocampbell@aol.com, 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’There are a few small errors such as $data for the array.
what with her make?
and what stay in Default Value in field all_data?
You don’t need anything in the default value. Leave it empty,
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;
$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]
I download php snippet plugin
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
The topic ‘get more data’ is closed to new replies.