Skip to main content
Topic: Display a notice to members without custom profile field  (Read 1639 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Display a notice to members without custom profile field

Hi all, 
I recently changed some custom profile fields and I added 2 new dropdown fields. Is there a way to show a notice only to registered members which didn't fill those 2 custom fields? something like: "It looks that your profile is not fully completed, click here to edit your profile. Once completed you won't see this notice anymore"

I could use simple portal for this without editing the core files

Thank you in advance
sorry for my bad english

Re: Display a notice to members without custom profile field

Reply #1

There is no very easy way, it requires some code, mainly because custom fields are not loaded unless there is a reason to (e.g. show them in the topic/profile/registration), so there is to query the database to find out if the user has a value or not.

In general the code should look like:
Code: [Select]
	global $user_info;
$db = database();
$req = $db->query('', '
SELECT value
FROM {db_prefix}custom_fields_data
WHERE id_member = {int:member}
AND variable = {string:field_name}
LIMIT 1',
array(
'member' => $user_info['id'],
'field_name' => 'cust_abcdef'
)
);
if ($db->num_rows($req) == 0)
{
// show message
}

The only thing you have to change is the name of the field:
Code: [Select]
'field_name' => 'cust_abcdef'
the "abcdef" part.
Currently you have two ways to discover it:
1) guess it, it is usually built picking the first 6 letters (from a to z including specials), numbers, underscores (_) or minus signs (-) of the name of the field,
2) open phpmyadmin and find the field in elkarte_custom_fields table and picking the value of col_name column.
Bugs creator.
Features destroyer.
Template killer.

 

Re: Display a notice to members without custom profile field

Reply #2

Thanks for the input Emanuele, I'll try it 
sorry for my bad english