Add signature form to Membership2Pro

Hello,
URL: http://yourtechadvisors.com/account/?action=edit_profile
As discussed in another support ticket, you must have a preexisting form to integrate the Edit Signature textbox in to. So my question is, how can I integrate it in to the Membership2Pro account page? It should appear below the Biographic Info field.

There are 2 required functions, you can view them at the below link. Predrag Dubajic has login info for this link.
https://support.dev4press.com/kb/article/integrate-signatures-in-any-theme-or-plugin/

I am sorry for all the trouble, but I need this to be in a place where people can edit their signatures other than the Dashboard.

Screenshot: https://drive.google.com/file/d/0B_h6oU4LzDtlLVpxUS1tS25tWk0/view?usp=sharing

Thanks,
Alex :smiley:

  • Adam Czajczyk

    Hello Alex,

    It seems we meet again on this one again :slight_smile:

    Remembering your other thread, I can say that's not going to be easy as well. Adding a tab to BuddyPress is one thing and integrating that plugin to BP or any other place on your site is another. I'd say that if it was causing so much trouble there, it will cause no less (if not more) trouble here.

    Let's then start from scratch, would you mind? To summarize your goal:

    - you wish to implement signatures that will be automatically added to your bbPress forum
    - you'd like users to be able to set them up and edit in an easy and simple way, preferably on their WP Profile page

    Is that correct? Let me know please and also please add up to it if I missed anything.

    Does the solution have to use the plugin in question or you're ready to accept any solution that would work and meet requirements listed above?

    Best regards,
    Adam

  • Alex Stine

    Hello,
    A: It does not have to use this plugin, although it would be nice if we could make it work.
    B: Which one do you think would be easiest to do? This or the integration with BuddyPress?

    If it is easier with BuddyPress, we will go back to the other ticket, if not, we will stay here. I am just saying, we have an existing form here, where at BuddyPress we do not. It is up to you.

    Thanks,
    Alex :smiley:

  • Adam Czajczyk

    Hello Alex,

    Thank you for your response!

    I got some ideas but I must say that I'm a bit lost again. I reviewed your site again (I created myself an account again - subscriber/participant - so please keep it there until we're done with this issue) and it seems that the "signature feature" is there up and running. The only issue is that in order to edit it user would have to visit his/her WP profile and this is set to be not available for users on your site.

    In other words, the signature feature (including setting signature up and editing it) is working but you would like to "pull" the signature edit field to the front-end. Would that be right? Would it work for you? This changes perspective a bit :slight_smile:

    It's also worth noting that by default the signature edit filed should already be there on front-end but it's not visible on your site because your BuddyPress tabs are heavily customized and the standard "Profile -> Edit" tab is hidden.

    To sum it up, if we moved somehow signature filed from invisible "Profile -> Edit" tab to other (available) tab, would that do the trick for you?

    Best regards,
    Adam

  • Adam Czajczyk

    Hey Alex!

    I re-checked the site and also downloaded free version of the plugin that you're using. It seems that this is still to complex to be possible to handle as "support issue". I do however can propose yet another solution that actually does use Membership 2 Pro Account "Profile" edit form.

    Here's the way:

    1. Go to your dashboard's "Users -> Profile Fields" page and create new profile filed. Give it a name "Forum signature" and select type "Multi-line Text Area". Set it to "Not Required" and visible to "Everyone" and make sure that "Autolink" option is set to disabled.

    2. Go to "Membership 2 -> Settings -> Profile fields" page and the "Forum signature" filed will be available on the list. Select that it should show up on "Profile" edit page.

    At this point users should be able to go to their membership "Account -> Personal details" page and add/edit signature text.

    We now need to add it to bbPress forum posts and we'll utilize slightly altered code from the plugin that you were initially planning to use (the plugin is not necessary for this):

    add_filter('bbp_get_topic_content', 'bbp_sig_reply_content'), 10000, 2);
    add_filter('bbp_get_reply_content', 'bbp_sig_reply_content'), 10000, 2);
    
    function bbp_sig_reply_content($content, $reply_id = 0) {
            if ($reply_id == 0) {
                global $post;
                $user_id = $post->post_author;
            } else {
                $user_id = bbp_get_reply_author_id($reply_id);
            }
    
    		$args = array(
    			'field' => 'Forum signature',
    		}
    		$signature = bp_get_profile_field_data( $args );
    
            $content.= '<div class="bbp-signature">'.$signature.'</div>';
            }
    
            return $content;
        }
    }

    This code should work as follows:

    - be triggered when post and/or replay content is fetched from database
    - check an ID of bbPress user
    - read X-profile filed "Forum signature"
    - append it to fetched content before this content is displayed.

    Best regards,
    Adam

  • Alex Stine

    Hello,
    In the live chat, we tried to make the original code work, unfortunately, it was filled with errors so we had to try some different code. Unfortunately, we could never make it work. Could you please recommend some code that will achieves my goal? :slight_smile:

    This is the most recent code tried without any success.

    add_filter('bbp_get_topic_content', 'bbp_sig_reply_content', 10000, 2);
    add_filter('bbp_get_reply_content', 'bbp_sig_reply_content', 10000, 2);
    
    function bbp_sig_reply_content($content, $reply_id = 0) {
    if ($reply_id == 0) {
    global $post;
    $user_id = $post->post_author;
    } else {
    $user_id = bbp_get_reply_author_id($reply_id);
    }
    
    $args = array(
    'field' => 'Forum signature', );
    $signature = bp_get_profile_field_data( $args );
    
    $content.= '<div class="bbp-signature">'.$signature.'</div>';
    return $content;
    }

    Thanks,
    Alex :smiley:

  • Michael Bissett

    As for Part 2, the displaying of the signature, that was done with this code:

    function my_bbp_reply_content_append_user_signature( $content = '', $reply_id = 0, $args = array() ) {
    	// Default arguments
    	$defaults = array(
    		'separator' => '<hr />',
    		'before'    => '<div class="bbp-reply-signature">',
    		'after'     => '</div>'
    	);
    	$r = wp_parse_args( $args, $defaults );
    	extract( $r );
    
    	// Verify topic id, get author id and potential signature
    	$reply_id  = bbp_get_reply_id       ( $reply_id );
    	$user_id   = bbp_get_reply_author_id( $reply_id );
    
    	// Get fields data. Caution: name is case sensitive.
    	if(function_exists('bbpress') ) {
    		$signature = xprofile_get_field_data( 'Forum signature', $user_id );
    	}
    	else {
    		$signature = bbp_get_user_signature ( $user_id  );
    	}
    
    	// If signature exists, adjust the content accordingly
    	if ( !empty( $signature ) )
    		$content = $content . $separator . $before . $signature . $after;
    
    	return apply_filters( 'my_bbp_reply_content_append_signature', $content, $reply_id, $separator );
    }
    
    if ( !is_admin() ) {
       // remove the original BBPress filter
       remove_filter( 'bbp_get_reply_content', 'bbp_reply_content_append_user_signature', 1, 2 );
       // add our custom filter
       add_filter( 'bbp_get_reply_content', 'my_bbp_reply_content_append_user_signature', 1, 2 );
    }

    Hat tip to this fellow for the code inspiration:

    https://buddypress.org/support/topic/buddypress-bbpress-signature/

    Kind Regards,
    Michael

  • Alex Stine

    Hello,
    Alright, upon further tests, we still have some problems.
    A: It saves to the database successfully the first time.
    B: When you update the signature, it does not save, it reverts to the signature you put in first. It is like it will not save over what is already there.
    C: Tried clearing cache, did not help.
    D: Reinstalled Membership2Pro beta version, did not help.

    Any suggestions on how to fix this?

    Thanks,
    Alex :smiley:

  • Michael Bissett

    Hey Alex S,

    After running multiple tests, we're running into this due to the Memcached caching that SiteGround's caching plugin offers, disabling that gets changes to that field saved properly.

    Thing is, that feature's only got two options; on, and off. No exclusions look to be available.

    So in order for this to work properly, you'll need to have it disabled. If you re-enable it, it may seem like it's not a problem (as it seemed to me at first), but after the 2nd time of saving changes, you should see that changes are no longer showing up when you revisit the "Edit Profile" page.

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.