• Resolved project_subdomain

    (@project_subdomain)


    I’ve added two links to two different bbpress pages that link to the new-message page and shall autofill the username. The one I added on the user’s profile page works perfectly.

    <a class="send-message-link1" href="mysite/messages/?fepaction=newmessage&to=<?=preg_replace('/^wg_/i','',bbp_get_displayed_user_field('display_name'))?>">Message</a>

    Same href-part added via functions.php for my bbpress topic template results in a blank page. This code gets my site back but does not add any username to url (and no autofill):

    `$links[‘add_link’] .= ‘<a class=”send-message-link2″ href=”mysite/messages/?fepaction=newmessage&to=’.”. preg_replace(‘/^wg_/i’,”,bbp_get_displayed_user_field(‘display_name’)).'”>Message</a>’;
    `

    Suppose I missed some php rules right here as to above behavior by to amendmends. unusual highlighting of colors seem to give me that hint as well.

    Would be very happy about any help!
    [Sorry, dont get the backticks to work as they should]

    https://wordpress.org/plugins/front-end-pm/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    why are you using display_name instead of user_login? display_name is not always same as user_login. That time that will not work.

    So my suggestion use following code in profile page

    <a class="send-message-link1" href="<?php echo fep_action_url('newmessage'); ?>&to=<?php bbp_get_displayed_user_field('user_login'); ?>">Message</a>

    And for function.php i can not tell anything without seeing your full function.

    Thread Starter project_subdomain

    (@project_subdomain)

    thanks for helping, shamim!
    It is the only code I got to work, just on profile page however.
    Tried above code with user_login for profile page – this does not get the url into url or autofill.

    The full function which adds a new link to the header of each reply of topics(admin link):

    function new_add_bbp_admin_link( $links, $reply_id ) {
    
    	if ( is_user_logged_in() ) {
    
    	$links['add_link'] .= '<a class="send-message-link2" href="mysite/messages/?fepaction=newmessage&to='.''. preg_replace('/^wg_/i','',bbp_get_displayed_user_field('display_name')).'">Message</a>';
    }
    	return $links;
    }
    add_filter( 'bbp_reply_admin_links', 'new_add_bbp_admin_link', 10, 2 );
    Plugin Author Shamim Hasan

    (@shamim51)

    Plugin Author Shamim Hasan

    (@shamim51)

    for profile use

    <a class="send-message-link1" href="<?php echo fep_action_url('newmessage'); ?>&to=<?php echo bbp_get_displayed_user_field('user_login'); ?>">Message</a>

    and for function use

    function new_add_bbp_admin_link( $links, $reply_id ) {
    
    	if ( is_user_logged_in() && bbp_get_reply_author_id($reply_id) ) {
    
    	$links['add_link'] .= '<a class="send-message-link2" href="'. fep_action_url('newmessage').'&to='. fep_get_userdata(bbp_get_reply_author_id($reply_id), 'user_login', 'id').'">Message</a>';
    }
    	return $links;
    }
    add_filter( 'bbp_reply_admin_links', 'new_add_bbp_admin_link', 10, 2 );
    Thread Starter project_subdomain

    (@project_subdomain)

    ah missing echo at first one.
    works perfectly, great! thanks a lot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Autofill username – Supposed syntax error’ is closed to new replies.