Integration of Advanced Profile Fields

Started by nax_hh, December 10, 2009, 02:15:12 PM

Previous topic - Next topic

nax_hh

Hi guys, i making an integration of a website with smf

and i need to use the Advanced Profile Fields.

I have a select box with values like: 'barcelona' 'madrid' and others. (when you register you put where are you from)
in profile.template.php
i saw this:
if (!empty($context['custom_fields']))
so i think my custom select box are here
but what i need to integrate it ???

i have this:

<?php require_once("../smf/SSI.php"); function logued() { global $context, $user_info; $_SESSION['login_url'] = 'http://localhost' . $_SERVER['PHP_SELF']; $_SESSION['logout_url'] = 'http://localhost' . $_SERVER['PHP_SELF']; if ($context['user']['is_guest']) { ssi_login(); }else if ($context['user']['is_logged'] && in_array(4, $user_info['groups'])) { echo 'eres del grupo ORG<br />'; } foreach ($context['user'] as $user => $data) { echo $user.' => '.$data.'<br />'; } foreach ($user_info['groups'] as $info => $data) { echo $info.' => '.$data.'<br />'; } foreach ($context['custom_fields'] as $custom => $data) { echo $custom.' => '.$data.'<br />'; } ssi_logout();}logued();?>

but the last foreach don't work and if i do a foreach of $context, custom_fields are not in..
so.. wat i need to do?

All i want to do is something like this:

<?phpif ($context['custom_field']['provincia'] == 'Barcelona'){ echo 'you are from barcelona';}?>

but more advanced of course...

special thanks
nax

Andre N

Does the user even have anything in the custom field right now?

You could try putting print_r($context); die();
or putting print_r($context['custom_fields']); die();
at the top of the page to get the correct names for the fields and check if anything is in there. I've used the mod and if I remember correctly the names are like cp1, cp2 etc. by default
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

nax_hh

#2
well i think the trouble is when i require the SSI.php, the $context['custom_fields'] don't exists.

In the user profile i have the value "madrid"

when i do: (in my script)
    print_r($context);

i have these output:

Array ( [user] => Array ( [id] => 1 [is_logged] => 1 [is_guest] => [is_admin] => 1 [is_mod] => [can_mod] => 1 [username] => nax [language] => english [email] => [email protected] [ignoreusers] => Array ( ) [name] => nax [smiley_set] => default [messages] => 0 [unread_messages] => 0 [popup_messages] => [avatar] => Array ( ) [total_time_logged_in] => Array ( [days] => 0 [hours] => 1 [minutes] => 42 ) ) [linktree] => Array ( [0] => Array ( [url] => http://localhost/smf/index.php [name] => My Community ) ) [languages] => Array ( [english] => Array ( [name] => English [selected] => [filename] => english [location] => C:\xampp\htdocs\smf/Themes/default/languages/index.english.php ) [spanish_es-utf8] => Array ( [name] => Spanish Es-utf8 [selected] => [filename] => spanish_es-utf8 [location] => C:\xampp\htdocs\smf/Themes/default/languages/index.spanish_es-utf8.php ) ) [html_headers] => [menu_separator] => [session_var] => e63ab1cc [session_id] => f5efd64a48c2e7013d07def10cc76f89 [forum_name] => My Community [forum_name_html_safe] => My Community [current_action] => [current_subaction] => [show_login_bar] => [server] => Array ( [is_iis] => [is_apache] => 1 [is_lighttpd] => [is_cgi] => [is_windows] => 1 [iso_case_folding] => 1 [complex_preg_chars] => 1 [needs_login_fix] => ) [browser] => Array ( [is_opera] => [is_opera6] => [is_opera7] => [is_opera8] => [is_opera9] => [is_opera10] => [is_ie4] => [is_webkit] => [is_mac_ie] => [is_web_tv] => [is_konqueror] => [is_firefox] => 1 [is_firefox1] => [is_firefox2] => [is_firefox3] => 1 [is_iphone] => [is_chrome] => [is_safari] => [is_gecko] => 1 [is_ie8] => [is_ie7] => [is_ie6] => [is_ie5.5] => [is_ie5] => [is_ie] => [ie_standards_fix] => 1 [needs_size_fix] => 0 [possibly_robot] => ) [insert_after_template] => [template_layers] => Array ( [0] => html [1] => body ) [theme_variant] => [character_set] => ISO-8859-1 [utf8] => [right_to_left] => [tabindex] => 1 [admin_features] => Array ( [0] => cp ) [theme_loaded] => 1 [open_mod_reports] => 0 [in_maintenance] => [current_time] => December 11, 2009, 10:03:35 pm [show_quick_login] => [news_lines] => Array ( [0] => SMF - Just Installed! ) [fader_news_lines] => Array ( [0] => SMF - Just Installed! ) [random_news_line] => SMF - Just Installed! [unapproved_members] => 0 [show_open_reports] => 1 [allow_search] => 1 [allow_admin] => 1 [allow_edit_profile] => 1 [allow_memberlist] => 1 [allow_calendar] => [allow_moderation_center] => 1 [allow_pm] => 1 [menu_buttons] => Array ( [home] => Array ( [title] => Home [href] => http://localhost/smf/index.php [show] => 1 [sub_buttons] => Array ( ) [is_last] => [active_button] => 1 ) [help] => Array ( [title] => Help [href] => http://localhost/smf/index.php?action=help [show] => 1 [sub_buttons] => Array ( ) [active_button] => ) [search] => Array ( [title] => Search [href] => http://localhost/smf/index.php?action=search [show] => 1 [sub_buttons] => Array ( ) [active_button] => ) [admin] => Array ( [title] => Admin [href] => http://localhost/smf/index.php?action=admin [show] => 1 [sub_buttons] => Array ( [featuresettings] => Array ( [title] => Features and Options [href] => http://localhost/smf/index.php?action=admin;area=featuresettings [show] => 1 ) [packages] => Array ( [title] => Packages [href] => http://localhost/smf/index.php?action=admin;area=packages [show] => 1 ) [errorlog] => Array ( [title] => Error Log [href] => http://localhost/smf/index.php?action=admin;area=logs;sa=errorlog;desc [show] => 1 ) [permissions] => Array ( [title] => Permissions [href] => http://localhost/smf/index.php?action=admin;area=permissions [show] => 1 ) ) [active_button] => ) [moderate] => Array ( [title] => Moderate [href] => http://localhost/smf/index.php?action=moderate [show] => 1 [sub_buttons] => Array ( [reports] => Array ( [title] => Reported Posts [href] => http://localhost/smf/index.php?action=moderate;area=reports [show] => 1 ) ) [active_button] => ) [profile] => Array ( [title] => Profile [href] => http://localhost/smf/index.php?action=profile [show] => 1 [sub_buttons] => Array ( [summary] => Array ( [title] => Summary [href] => http://localhost/smf/index.php?action=profile [show] => 1 ) [account] => Array ( [title] => Account Settings [href] => http://localhost/smf/index.php?action=profile;area=account [show] => 1 ) [profile] => Array ( [title] => Forum Profile [href] => http://localhost/smf/index.php?action=profile;area=forumprofile [show] => 1 ) ) [active_button] => ) [pm] => Array ( [title] => My Messages [href] => http://localhost/smf/index.php?action=pm [show] => 1 [sub_buttons] => Array ( [pm_read] => Array ( [title] => Read your messages [href] => http://localhost/smf/index.php?action=pm [show] => 1 ) [pm_send] => Array ( [title] => Send a message [href] => http://localhost/smf/index.php?action=pm;sa=send [show] => 1 ) ) [active_button] => ) [mlist] => Array ( [title] => Members [href] => http://localhost/smf/index.php?action=mlist [show] => 1 [sub_buttons] => Array ( [mlist_view] => Array ( [title] => View the memberlist [href] => http://localhost/smf/index.php?action=mlist [show] => 1 ) [mlist_search] => Array ( [title] => Search For Members [href] => http://localhost/smf/index.php?action=mlist;sa=search [show] => 1 ) ) [active_button] => ) [logout] => Array ( [title] => Logout [href] => http://localhost/smf/index.php?action=logout;e63ab1cc=f5efd64a48c2e7013d07def10cc76f89 [show] => 1 [sub_buttons] => Array ( ) [is_last] => 1 [active_button] => ) ) [show_news] => 1 [show_pm_popup] => [common_stats] => Array ( [total_posts] => 4 [total_topics] => 4 [total_members] => 4 [latest_member] => Array ( [id] => 4 [name] => username [href] => http://localhost/smf/index.php?action=profile;u=4 [link] => username  ) ) [page_title] => [page_title_html_safe] => ..etc

nothing about Madrid Custom_profile or CP as you can see.

when i do
    print_r($context['custom_fields']);
i don't have output.

i need to know what to do, or wich file import, to have the data of custom_fields.

I really need it!

thanks

pd. is not a mod, i'm using rc 2.0

Orstio

With SSI.php, you often need to use $user_info instead of $context.

nax_hh

function logued() {
global $context, $user_info;


as you can see i'm using both, but i think i can use $user_info only.

But, where is ['custom_fields'] in $user_info
or where i can found it?
thanks
nax

Orstio

WHat does it do if you print_r($user_info) ?

nax_hh

#6
Array ( [groups] => Array ( [0] => 1 [1] => 4 ) [possibly_robot] => [id] => 1 [username] => nax [name] => nax [email] => [email protected] [passwd] => 1dd0e9b56fd21b5a455edeb6a9121a92407af063 [language] => english [is_guest] => [is_admin] => 1 [theme] => 0 [last_login] => 1260565380 [ip] => 127.0.0.1 [ip2] => 127.0.0.1 [posts] => 3 [time_format] => %B %d, %Y, %I:%M:%S %p [time_offset] => 0 [avatar] => Array ( [url] => [filename] => [custom_dir] => [id_attach] => 0 ) [smiley_set] => default [messages] => 0 [unread_messages] => 0 [total_time_logged_in] => 6161 [buddies] => Array ( ) [ignoreboards] => Array ( ) [ignoreusers] => Array ( ) [warning] => 0 [permissions] => Array ( ) [query_see_board] => 1=1 [query_wanna_see_board] => 1=1 [is_mod] => [mod_cache] => Array ( [time] => 1260549888 [id] => 1 [gq] => 1=1 [bq] => 1=1 [ap] => Array ( [0] => 0 ) [mb] => Array ( ) [mq] => 0=1 ) )

nax_hh

well finally i found in the smf_themes the values of the custom fields.

SO i'm thinkig to do a query to take these values...

if anyone know a best way to take it please say me

thanks a lot
nax

Kill Em All

nax_hh, do you need further help with this?


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

nax_hh


Advertisement: