Skip to:
Content
Pages
Categories
Search
Top
Bottom

oEmbed in BP Profile Field

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

    Moderator

    Hi @myg0t,

    Try doing this:

    function my_oembed_function( $value ) {
        global $wp_embed;
        $value = $wp_embed->autoembed( $value );
        return $value;
    }
    add_filter( 'bp_get_the_profile_field_value', 'my_oembed_function' );

    Please note I’ve not had a chance to test.

    I’m assuming bp_get_the_profile_field_value is the right hook here. Grateful if someone could shout out if I’m wrong.

    @myg0t

    Participant

    @henrywright Thanks for the reply!

    unfortunately, that did not work.

    I tried putting it in both my childtheme/functions.php and my plugins/buddypress/bp-custom.php and no dice. :\

    @naijaping

    Participant

    @myg0t, try the code below

    // Enable oembed  in profile
    function bp_youtube_in_profile() {
      add_filter( 'bp_get_the_profile_field_value', 'bp_enable_youtube_in_profile', 9, 3 );
    }
    add_action( 'bp_init', 'bp_youtube_in_profile', 0 );
    
    function bp_enable_youtube_in_profile( $val, $type, $key ) {
    
    	$field = new BP_XProfile_Field( $key );
    	$field_name = $field->name;
    
    	$val = strip_tags( $val );
    	
    	if(  strtolower( $field_name ) == 'YOUR FIELD NAME' ) {
    		return wp_oembed_get( $val, array('width'=>300) );	
    	}
    		return $val;
    }

    @henrywright

    Moderator

    @myg0t I think the problem is with the hook I’ve used. How did you get on with @naijaping’s code?

    @myg0t

    Participant

    @naijaping Sadly, it is not working still 🙁

    I tried the code in both childtheme/functions.php and plugins/buddypress/bp-custom.php…

    Just to clarify I should be using a link like this, yes?

    thanks guys,

    \M

    @aces

    Participant

    @myg0t

    I haven’t tried the above code, but the location of bp-custom.php should be /wp-content/plugins/bp-custom.php not the buddypress plugin directory.

    @myg0t

    Participant

    @aces

    hmmm… Your exactly right… Now that you say that, I had it in the plugins folder at one point, but some where along the lines I some how moved it over to the buddypress folder.. Not sure why…

    Either way, I moved it back to the plugins folder and still nothin’ 🙁

    @naijaping

    Participant

    @myg0t,

    did you remember to change the field name (YOUR FIELD NAME)to the name you call it in your?

    I am currently using the code and working fine for me.

    @myg0t

    Participant

    Hmm, yes I did.

    Just to clarify, it should be fine putting this in my functions.php, right?

    This is what I have:

    // Enable oembed  in profile
    function bp_youtube_in_profile() {
      add_filter( 'bp_get_the_profile_field_value', 'bp_enable_youtube_in_profile', 9, 3 );
    }
    add_action( 'bp_init', 'bp_youtube_in_profile', 0 );
    
    function bp_enable_youtube_in_profile( $val, $type, $key ) {
    
    	$field = new BP_XProfile_Field( $key );
    	$field_name = $field->name;
    
    	$val = strip_tags( $val );
    	
    	if(  strtolower( $field_name ) == 'Spotlight Video' ) {
    		return wp_oembed_get( $val, array('width'=>300) );	
    	}
    		return $val;
    }

    I assume spaces in the field name aren’t an issue right?

    thanks,

    \M

    @naijaping

    Participant

    @myg0t,

    space could be an issue, try a single name and also it is case sensitive.

    regards

    @myg0t

    Participant

    Yeah, still nothin 🙁

    I’ve also tried making the field a text box instead of a text-area. That didn’t change anything either lol.

    I just tested Oembed in an activity stream and it works fine..

    No clue whats going on here…

    Thanks for all help @naijaping!

    \M

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘oEmbed in BP Profile Field’ is closed to new replies.
Skip to toolbar