latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Custom fields for user profiles

Home Forums Community Forum Custom fields for user profiles

This topic contains 7 replies, has 2 voices. Last updated by  Raam Dev 4 years, 9 months ago.

Topic Author Topic
Posted: Wednesday Mar 28th, 2012 at 4:06 pm #9366
Simon Cooke
Username: Simon23

Hi.

I have found an excellent developers plugin that allows you to create custom meta fields (in profiles, pages and posts) in a really powerful and easy way, by adding code to your functions php file in the theme.

You can even scope your custom fields, applying them to specific roles

I have tested this and it works great – however what I now want to do it add the custom plugin code to the relevant part of the S2 plugin so that the custom fields show up in the native S2 front-end profile management.

Can anyone tell me where to place the code to do this?

The reason for all this is so that I can create better structured meta data for profiles which I am using elsewhere.

Custom code example:

if ( function_exists( ‘slt_cf_register_box’) )
add_action( ‘init’, ‘register_my_custom_fields’ );

function register_my_custom_fields() {
slt_cf_register_box( array(
‘type’ => ‘user’,
‘title’ => ‘Extra fields’,
‘id’ => ‘extra-fields’,
‘context’ => ‘normal’,
‘priority’ => ‘default’,
‘fields’ => array(
array(
‘name’ => ‘seller-countries’,
‘label’ => ‘In which countries do you currently supply?’,
‘type’ => ‘checkboxes’,
‘scope’ => array( ‘subscriber’,’s2member level 2′ ),
‘options’ => array( ‘USA’ => ‘USA’, ‘Canada’ => ‘Canada’, ‘France’ => ‘France’ , ‘Switzerland’ => ‘Switzerland’ , ‘Austria’ => ‘Austria’ , ‘Italy’ => ‘Italy’ , ‘Andorra’ => ‘Andorra’ , ‘Bulgaria’ => ‘Bulgaria’ , ‘Solvakia’ => ‘Solvakia’ , ‘Sweden’ => ‘Sweden’ , ‘Finalnd’ => ‘Finalnd’ , ‘Japan’ => ‘Japan’ , ‘Russia’ => ‘Russia’ , ‘Norway’ => ‘Norway’ , ‘Argentina’ => ‘Argentina’ , ‘Chile’ => ‘Chile’ , ‘Solvenia’ => ‘Solvenia’ , ‘Other’ => ‘Other’ )
)
)
));
}

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Wednesday Mar 28th, 2012 at 6:45 pm #9398
Raam Dev
Username: Raam
Staff Member

Hi Simon,

s2Member stores its custom registration fields (Dashboard -› s2Member® -› General Options -› Registration/Profile Fields) in its own way in the database, so simply “adding” to those isn’t going to be straight-forward.

However, if you simply want to display your custom fields alongside the front-end s2Member profile fields (i.e. when using the s2Member-Profile shortcode), then you may want to look at s2member/includes/classes/profile-in.inc.php.

Posted: Wednesday Mar 28th, 2012 at 7:01 pm #9404
Simon Cooke
Username: Simon23

HEY, thanks

I think it will work if I simply display them alongside as I dont need these fields in registration.

Is my code above ok to work out of the box or will I need to modify it at all, within the profile-in.inc.php ?

joe

Posted: Wednesday Mar 28th, 2012 at 7:03 pm #9405
Simon Cooke
Username: Simon23

to be clear – I need my fields to be manageable in users front end profile (which is an s2 screen)

joe

Posted: Wednesday Mar 28th, 2012 at 7:04 pm #9406
Raam Dev
Username: Raam
Staff Member

Hi Joe,

The code above only registers the custom fields and adds data to them; it doesn’t display the custom fields on the front-end, so you’d definitely need to use different code for that.

Posted: Wednesday Mar 28th, 2012 at 7:17 pm #9408
Simon Cooke
Username: Simon23

you re right

it displays the fields in the backend profile management – but I guess WP is providing that

i could just lift code from WP ?

or use some of the plugin functions to add editable fields to front end profiles

joe

Posted: Thursday Mar 29th, 2012 at 9:33 am #9454
Simon Cooke
Username: Simon23

Can you help ?

I have managed to use the plugin: Developer’s custom fields, to register a custom field for an s2member role:

The new field now shows in the back-end edit-user screen for only that user role.

GREAT

I need to get this new field to be editable in the s2member front-end user profile management screen.

The answer is here in the plugin’s documentation, but I am not experienced enough to work out how to do it

http://sltaylor.co.uk/wordpress/plugins/slt-custom-fields/docs/

I know I have to edit the s2member plugin here:

s2member/includes/classes/profile-in.inc.php

But I need someone to tell me what code from the plugin documentation to add to the above php file

Help ?

joe

Posted: Thursday Mar 29th, 2012 at 10:15 pm #9522
Raam Dev
Username: Raam
Staff Member

Hi Simon,

As per our support policy, we cannot assist with custom coding or integrating with 3rd party plugins (please see s2Member® » Support Policy » Outside Scope).

Viewing 7 replies - 1 through 7 (of 7 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.