BuddyDev

Search

Contact form – Show on profile

Tagged: 

  • Participant
    Level: Initiated
    Posts: 6
    tom0 on #33709

    Hi there
    How can I:
    1) Always show this on a user’s profile? I.e. avoid showing this as a separate tab?
    2) Change the fields?
    Thank you

  • Participant
    Level: Initiated
    Posts: 6
    tom0 on #33711

    Would it be something like:

    function bpucf_render_forms() {
    	add_action( 'bp_after_profile_content', 'bpucf_load_form' );
    	bp_core_load_template( array( 'members/single/plugins' ) );
    }

    please?
    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 19859
    Brajesh Singh on #33734

    Hi,
    Thank you for using the plugin.

    1. I am sorry but I do not understand this question. If you do not want to show it in a tab, how do you want to show it?

    2. Please give me some example to allow me check if it can be done or not?

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    tom0 on #33995

    Hi Brajesh
    I’d like to show the contact form on the profile itself — i.e. rather than showing it as a tab, I’d like to show it underneath the existing profile content please
    THanks

  • Keymaster
    (BuddyDev Team)
    Posts: 19859
    Brajesh Singh on #34010

    Hi,
    Thank you.

    I am still a bit confused(showing it in profile header or the page showing user profile data). Is there way you can take a screenshot of the profile page and mark a location where this form should appear? That will help me greatly.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    tom0 on #34154

    Hi Brajesh
    I’d like to add the contact us from here please: https://take.ms/uOVeR i.e. straight underneath the user’s profile data
    Thanks!

  • Keymaster
    (BuddyDev Team)
    Posts: 19859
    Brajesh Singh on #34168

    Hi Tom,
    Thank you.

    It makes a lot more sense now. One of us will get back to you tomorrow with the feasibility.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    tom0 on #34461

    Hi Brajesh
    Is this possible please?
    Thanks a lot!

  • Keymaster
    (BuddyDev Team)
    Posts: 19859
    Brajesh Singh on #34475

    Hi Tom,
    I am sorry, we have missed it earlier. @ravisharma will post and update to the plugin and provide you with the code to achieve it on Monday.

    Thank you
    Brajesh

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1951
    Ravi on #34496

    Hello Tom,

    Please try the following code and let me know if it works or not.

    
    /**
     * Render contact form after profile loop
     */
    function buddydev_after_profile_loop_render_contact_form() {
    
    	if ( ! function_exists( 'bpucf' ) ) {
    		return;
    	}
    
    	$is_visible = bpucf_is_form_visible( bp_displayed_user_id() );
    
    	if ( ! $is_visible ) {
    		return;
    	}
    
    	echo '<h4>' . __( 'Contact Me' ) . '</h4>';
    	// Render contact form after profile loop.
    	bpucf_load_form();
    }
    add_action( 'bp_after_profile_loop_content', 'buddydev_after_profile_loop_render_contact_form' );
    
    /**
     * Modify contact user form fields
     *
     * @param array $fields Form fields.
     *
     * @return mixed
     */
    function buddydev_modify_form_fields( $fields ) {
    
    	$fields['city'] = array(
    		'name'     => 'city',
    		'type'     => 'text',
    		'label'    => __( 'City', 'buddypress-user-contact-form' ),
    		'required' => false,
    		'position' => 4,
    	);
    
    	return $fields;
    }
    add_filter( 'bpucf_form_fields', 'buddydev_modify_form_fields' );
    
    /**
     * Append your field data to the message
     *
     * @param string $message Message content.
     *
     * @return string
     */
    function buddydev_modify_message_content( $message ) {
    
    	if ( ! empty( $_POST['city'] ) ) {
    		$city = sanitize_text_field( $_POST['city'] );
    		$message .= __( 'City: ' ) . $city;
    	}
    
    	return $message;
    }
    add_filter( 'bpucf_message_content', 'buddydev_modify_message_content' );
    
    

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved