Skip to:
Content
Pages
Categories
Search
Top
Bottom

oEmbed in BP Profile Field

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

  • Henry Wright
    Moderator

    @henrywright

    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

    @myg0t

    @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. :\

    @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;
    }

    Henry Wright
    Moderator

    @henrywright

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


    Myg0t
    Participant

    @myg0t

    @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

    @aces

    @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

    @myg0t

    @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’ 🙁

    @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

    @myg0t

    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

    @myg0t,

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

    regards


    Myg0t
    Participant

    @myg0t

    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