Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating xProfiles using functions.php


  • Hardeep Asrani
    Participant

    @hardeepasrani

    I wanted to create a function which will automatically add a xProfile field. Is it possible to do it using a custom plugin or functions.php?

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

  • shanebp
    Moderator

    @shanebp

    Yes.
    Start by taking a look at :

    function xprofile_insert_field() in bp-xprofile\bp-xprofile-functions.php


    Hardeep Asrani
    Participant

    @hardeepasrani

    Thanks for passing the info 🙂


    Hardeep Asrani
    Participant

    @hardeepasrani

    I used the following code, and it’s not doing the job:

    function field_xprofile_twitter()
    {
    
    $group_args = array(
         'name' => 'Social Networks'
         );
    $group_id = xprofile_insert_field_group( $group_args ); // group's ID
    
    xprofile_insert_field(
        array (
               field_group_id  => $group_id,
               name            => 'Twitter',
               can_delete      => false,
               field_order  => 1,
               is_required     => false,
               type            => 'textbox'
        )
    );
    }

    Hope you can help 🙂


    shanebp
    Moderator

    @shanebp

    Are you sure group_id is being set?

    Take another look at :
    function xprofile_insert_field() in bp-xprofile\bp-xprofile-functions.php

    Try passing an array to $args for xprofile_insert_field
    Like you did with xprofile_insert_field_group

    $args = your array;

    xprofile_insert_field( $args );


    Hardeep Asrani
    Participant

    @hardeepasrani

    This isn’t doing the job either:

    function field_xprofile_twitter()
    {
    
    $group_args = array(
         'name' => 'Social Networks'
         );
    $group_id = xprofile_insert_field_group( $group_args ); // group's ID
    
    xprofile_insert_field( $xfield_args );
    $xfield_args =  array (
               field_group_id  => $group_id,
               name            => 'Twitter',
               can_delete      => false,
               field_order  => 1,
               is_required     => false,
               type            => 'textbox'
        );
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Creating xProfiles using functions.php’ is closed to new replies.
Skip to toolbar