Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hook to Add New Field Group

  • Profile photo of coolstory
    coolstory
    Member

    @coolstory

    Hello everyone!
    I am developing a BP plugin that needs to create one field group when it gets activates. I can easily do it using $wpdb->insert just like this:

    
    function add_profile_group() {
    global $wpdb;
    $wpdb->insert(
    $wpdb->prefix . 'bp_xprofile_groups',
    array(
    'name' => 'Cool Group Name',
    'description' => 'blah blah blah ',
    'group_order' => 0,
    'can_delete' => 0
    )
    );
    }
    
    register_activation_hook(__FILE__,'add_profile_group');
    

    and then remove it on deactivation

    
    function remove_profile_group() {
    global $wpdb;
    $wpdb->query("DELETE FROM {$wpdb->prefix}bp_xprofile_groups WHERE name = 'Cool Group Name'");
    }
    
    register_deactivation_hook( __FILE__, 'remove_profile_group' );
    

    So is there any way to do it using BP hooks only?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Profile photo of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    xprofile_insert_field_group()

    Profile photo of coolstory
    coolstory
    Member

    @coolstory

    
    $args = array(
    'name'           => 'Test',
    'description'    => ' ',
    'can_delete'     => 0
    );
    xprofile_insert_field_group( $args );
    

    thats what I found. but the problem is it ignores can_delete and simply puts 1 (i tried both false and 0)…

    and why xprofile_insert_field() doesn’t accept ‘type’ => ‘option’? I need to add some checkboxes but it doesnt let me do it :(

    UPD:
    //HACK: to allow options

    global $bp;
    (array)$bp->profile->field_types[] = 'option';
    Profile photo of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    If you think a parameter isn’t working as it should, please report a bug to BuddyPress.trac.WordPress.org.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hook to Add New Field Group’ is closed to new replies.
Skip to toolbar