News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Missing integration hook on profile pages

Started by asmith, March 13, 2016, 06:31:13 AM

Previous topic - Next topic

asmith

Hello,

In Profile-Modify.php, I can use "integrate_load_profile_fields" to add my own custom fields. But how do I add the new fields say into account settings page? (without touching SMF code)

In this function:
function account($memID)

We have:

setupProfileContext(
array(
'member_name', 'real_name', 'date_registered', 'posts', 'lngfile', 'hr',
'id_group', 'hr',
'email_address', 'show_online', 'hr',
'tfa', 'hr',
'passwrd1', 'passwrd2', 'hr',
'secret_question', 'secret_answer',
)
);



Shouldn't there be an integration hook so that we could modify that array?

Same issue with other profile functions as well:
function forumProfile($memID)

Suki

Thank you for your suggestion will make sure to add a hook on setupProfileContext() function.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

asmith

Thank you. If you want I can make an "issue" for this on github.

Suki

Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

asmith

Thank you!

Just to clear things, you've put an integration hook with a constant name "integrate_setup_profile_context" to modify $fields directly into setupProfileContext. How one is supposed to know which set of fields is sent? is it "account" page fields? is it "forumProfile" fields? is it "theme" page fields?

There's $context['menu_item_selected'] available at that point. Did you intend the hook to check via $context['menu_item_selected'] to determine the $fields set identity?

function custom_integrate_setup_profile_context(&$fields)
{
     global $context;

     if ($context['menu_item_selected'] == 'account')
          $fields[] = 'new_field';
}

Suki

You can listen to the _GET or REQUEST var.

The hook is intended to be as generic as possible, no checks at all, whoever wants to implement the hook needs to do their own checks. This is to make sure the hook is as generic as possible.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

asmith


Advertisement: