This topic has 10 replies, 2 voices, and was last updated 10 years by santee.

  • Author
  • #32019
     santee
    Participant

    Hi !
    I would put the button “book this artist” on the profile of a member who sent the message to me and not directly to the member.
    Is this possible?

    thank you very much

    Attachments:
    You must be logged in to view attached files.
    #32021
     sharmstr
    Moderator

    Try this. Change ‘yourusername’ in the code below to your username. Put the following into your functions.php file

    COPY CODE
    
    add_action( 'bp_before_member_header_meta', 'book_artist');
    function book_artist(){
     	$link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=yourusername' );
    	echo bp_book_artist_button($link);
     
    }
    function bp_book_artist_button($link) {
    	return apply_filters( 'bp_get_send_message_button',
    	bp_get_button( apply_filters( 'bp_get_send_message_button_args', array(
    				'id'                => 'book_artitst',
    				'component'         => 'messages',
    				'must_be_logged_in' => true,
    				'block_self'        => true,
    				'wrapper_id'        => 'send-private-message',
    				'link_href'         => $link,
    				'link_title'        => __( 'Book this artist.', 'buddypress' ),
    				'link_text'         => __( 'Book Artist', 'buddypress' ),
    				'link_class'        => 'send-message',
    		) ) )
    		);
    	}
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #32023
     santee
    Participant

    Thank you 🙂
    i put this in buddypress-funtions.php or function.php ?

    thanx!!!

    #32024
     sharmstr
    Moderator

    Had a thought that you might want to auto populate the subject and maybe the message so you know what artist they want to book. The code I gave you before will only start the message and would rely on the person sending it to remember to put the artist name in. Anyhow, I found some code that should do this. So, instead of the code I gave you before, try this.

    COPY CODE
    
    add_action( 'bp_before_member_header_meta', 'book_artist');
    function book_artist(){
    	global $bp;
     	//$link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=tnsficadmin' );
    	$link = bp_custom_get_send_private_message_link('Booking Request for: ' . bp_core_get_username( bp_displayed_user_id() ),'Predefined message Information');
    	echo bp_book_artist_button($link);
     
    }
    
    function bp_custom_get_send_private_message_link($subject=false, $message=false) {
     
    //if user is not logged, do not prepare the link
    if ( !is_user_logged_in() ) return false;
     
    		$compose_url=bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=yourusername';
    			if($subject)
    			$compose_url.=('&subject='.$subject);
    			if($message)
    			$compose_url.=('&content='.$message);
     
    		return wp_nonce_url( $compose_url ) ;
    }
     
    /* 
    	Auto populate the message content
    */
    add_filter('bp_get_messages_content_value','bp_custom_message_content_value');
     
    function bp_custom_message_content_value($content){
     
    	if(!empty ($content)) return $content;
    	$content=$_REQUEST['content'];
    	return $content;
    }
     
    /* 
    	Auto Populate subject
     
    */
    add_filter('bp_get_messages_subject_value','bp_custom_get_messages_subject_value');
     
    function bp_custom_get_messages_subject_value($subject){
     
    	if(!empty($subject))
    		return $subject;
     
    	$subject=$_REQUEST['subject'];
     
    	return $subject;
    }
    

    Some things to note
    1 – Change ‘yourusername’ to your actual username.
    2 – You can edit the subject by changing ‘Booking Request for: ‘
    3 – You can change the message body by changing ‘Predefined message Information’. If you dont want a predefined message, the set it to ”.

    Credit goes to the code found here: https://gist.github.com/digitalchild/02c0730deebb3e3fca68

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #32025
     sharmstr
    Moderator

    as I said

    Put the following into your functions.php file

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #32028
     santee
    Participant

    Thank you !
    But it does not work properly. The button appears on each member of the list and when I click it, I get on the profile page of the member. The button is not displayed and all completely disappeared (information, media, profile) and there are no form to send a message.
    Style is also broken. (Header, main)
    Any idéa??

    thank you

    #32029
     santee
    Participant

    I wish it was the user online and offline that can see what the artist booker for Button and send me a message

    #32031
     sharmstr
    Moderator

    A user cant send a private message unless they are logged in. That’s just the way it is. If you want non-logged in users to send you a message, then take a look at the Contact Form 7.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #32034
     santee
    Participant

    Ok. Good idea. I would have to create a button on the profile of the member who returns to the form.
    But how then put a button under the member’s avatar?

    Thanx

    #32037
     sharmstr
    Moderator

    The add action line at the top of my code injects stuff exactly where it says it does ‘bp_before_member_header_meta’.

    add_action( ‘bp_before_member_header_meta’, ‘your_button_code’);

    Someone has probably asked for something similar over at Contact Form 7. Search there or google it.

    In the future, please be as specific as possible when requesting help. I wasted an hour on this.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #32038
     santee
    Participant

    Ok sorry I wasted your time.
    thank you very much

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

The topic ‘Add "contact" button on member page?’ is closed to new replies.

Log in with your credentials

Forgot your details?