Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • @bobsd99

    Participant

    Note: there is no transcription error, the field 315 references the allowed values for field 307

    @bobsd99

    Participant

    Found it, I think:

    $field = xprofile_get_field( 315 );
    echo "Field name: " . $field->name; 
    // Field name: Subscribe to Free Newsletter

    @bobsd99

    Participant

    A quick followup, I see the permitted field value for the checkbox (in this case) is stored in field 315 in table wp_bp_xprofile_fields – how do I query this checkbox setting value?

    I want to pull the correct value from the database, so in case I update that checkbox field’s option in the backend, I can correctly set it.

    I don’t see a function in /buddypress/bp-xprofile/bp-xprofile-functions.php: that seems to pull this, and nothing is locking in with Google….

    @bobsd99

    Participant

    So simple! Not obvious, though. I couldn’t even find xprofile_set_field_data documented in the Codex (although xprofile_get_field_data is). Thanks Shane, not the first time you’ve dug me out :o)

    @bobsd99

    Participant

    To keep this simple, and for illustration purpose, I edited the data I wanted to update in the question, which given it’s a checkbox, is confusing.

    I actually want to toggle that element off, so I assume I’d actually either a) update the array to an empty field, or b) delete the entry entirely.

    I assume I want to change the field to an empty string, but now that doesn’t seem as obvious. Some guidance is appreciated on updating this field and any curves a checkbox might throw in working with BP XProfile fields.

    @bobsd99

    Participant

    Double d’oh! I wasn’t logged in when I tested it just now. I was right, it was a dumb question. Thanks Shane!

    @bobsd99

    Participant

    D’oh, I wanted a generic testing function and that obviously wouldn’t work in that context.

    However, I did change it to the function you suggested and it’s still not outputting data. There must be a missing step in loading and making BuddyPress functions available in my own custom template pages.

    @bobsd99

    Participant

    Bingo! Thanks Henry… 🙂

    @bobsd99

    Participant

    I didn’t have any luck with the wp_title() function/hook either, so I’ll next climb into the core a bit to see if I can get anywhere. Reference and implementations for title functions in BuddyPress seem to be scarcely documented on the web, so I was hoping to get some insight from the experts here, as well as leave a few breadcrumbs for developers in the future. That could be especially helpful as WP/BP transition away from the wp_title() function.

    @bobsd99

    Participant

    Hi Henry – thanks for response. As confirmed by both the Codex (Code Reference) and my successful use of this method in the same installation outside of BuddyPress, $title is indeed an array.

    In fact, I tested my function without the if ( bp_is_group() ){ conditional, and the filter works on the pages NOT created/affected by BuddyPress, which confirms BuddyPress is bypassing this filter.

    For testing purposes, I modified the function as follows:

    // test parameters passed to document_title_parts filter
    function test_groups_title( $title ){
    
    	print_r( $title );
    	exit;
    
    }
    add_filter('document_title_parts', 'test_groups_title', 10);

    And BuddyPress pages output the following array:

    Array
    (
        [title] => 
        [site] => My-Website.com
    )

    Which suggests that BuddyPress is neither supplying data to this array nor utilizing it for the title output.

    I did a grep of BuddyPress and bbPress and I am finding calls to the deprecated wp_title() function:

    $ grep -r 'wp_title' ../plugins/b*press/*
    ../plugins/bbpress/includes/core/filters.php:add_filter( 'wp_title',                'bbp_title',              10, 3 );
    ../plugins/bbpress/readme.txt:* Fix custom wp_title compatibility
    ../plugins/buddypress/bp-core/bp-core-filters.php: * @see wp_title()
    ../plugins/buddypress/bp-core/bp-core-filters.php:       * @see wp_title()
    ../plugins/buddypress/bp-core/bp-core-filters.php:       * Filters the older 'wp_title' page title for BuddyPress pages.
    ../plugins/buddypress/bp-core/bp-core-filters.php:add_filter( 'wp_title',             'bp_modify_page_title', 20, 3 );
    ../plugins/buddypress/bp-core/deprecated/1.5.php: * @deprecated Use wp_title()
    ../plugins/buddypress/bp-core/deprecated/1.5.php:        * Now, just simply use wp_title().
    ../plugins/buddypress/bp-core/deprecated/1.5.php:        * @deprecated Use wp_title()
    ../plugins/buddypress/bp-core/deprecated/1.5.php:               _deprecated_function( __FUNCTION__, '1.5', 'wp_title()' );
    ../plugins/buddypress/bp-core/deprecated/1.5.php:               $title = wp_title( '|', false, 'right' ) . get_bloginfo( 'name', 'display' );
    ../plugins/buddypress/bp-themes/bp-default/header.php:          <title><?php wp_title( '|', true, 'right' ); bloginfo( 'name' ); ?></title>
    ../plugins/buddypress/bp-themes/bp-default/archive.php:                 <h3 class="pagetitle"><?php printf( __( 'You are browsing the archive for %1$s.', 'buddypress' ), wp_title( false, false ) ); ?></h3>

    I guess this means I can and should hook in to the older (deprecated) wp_title() function? I’m a bit new to BuddyPress and WordPress, so maybe I’m missing something obvious, or barking up the wrong tree here….

    @bobsd99

    Participant

    I think you may want the funtion wp_extract_urls().

    So for example:

    $url = wp_extract_urls( xprofile_get_field_data( '23', $user->ID ) );
    echo "URL: $url[0]";

    New to WP coding but this worked for me…

Viewing 11 replies - 1 through 11 (of 11 total)
Skip to toolbar