Skip to:
Content
Pages
Categories
Search
Top
Bottom

PHP help links in bp_core_add_message


  • ewebber
    Participant

    @ewebber

    Hi,
    I have a plug that I am using and I want to add an html link into the message in this code:

    `bp_core_add_message( __( ‘Your account is now active!’,’buddypress’ ) );`

    I try with PHP, but my skills are very limited, can anyone help me.

    Thanks

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

  • r-a-y
    Keymaster

    @r-a-y

    Haven’t tested this, but try adding your message in a variable:

    `
    $message = ‘

    This is my message with a link

    ‘;

    bp_core_add_message( $message );
    `


    ewebber
    Participant

    @ewebber

    Hi @r-a-y thanks for the message, but that seems to return the variable as plain text too, hmmmm?


    r-a-y
    Keymaster

    @r-a-y

    @ewebber – Just checked. Yeah the message gets escaped, so you can’t add HTML by default.

    If you want to add HTML, you’ll have to remove how BP renders the message, then you’ll have to write your own custom message function.

    Untested, but this should work in your theme’s functions.php:

    `
    remove_action( ‘wp’, ‘bp_core_setup_message’, 2 );

    function my_bp_core_setup_message() {
    global $bp;

    if ( empty( $bp->template_message ) )
    $bp->template_message = $_COOKIE;

    if ( empty( $bp->template_message_type ) )
    $bp->template_message_type = $_COOKIE;

    add_action( ‘template_notices’, ‘my_bp_core_render_message’ );


    @setcookie
    ( ‘bp-message’, false, time() – 1000, COOKIEPATH );

    @setcookie
    ( ‘bp-message-type’, false, time() – 1000, COOKIEPATH );
    }
    add_action( ‘wp’, ‘my_bp_core_setup_message’, 2 );

    function my_bp_core_render_message() {
    global $bp;

    if ( $bp->template_message ) {
    $type = ( ‘success’ == $bp->template_message_type ) ? ‘updated’ : ‘error’;
    ?>
    <div id="message" class="”>

    template_message; ?>

    <?php
    do_action( ‘bp_core_render_message’ );
    }
    }`


    ewebber
    Participant

    @ewebber

    @r-a-y thanks, I will give it a go

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP help links in bp_core_add_message’ is closed to new replies.
Skip to toolbar