BP Activity Plus Not Including Message Along With Image and Link Activity Posts

BuddyPress Activity Plus doesn't include a message to go along with link and image activity updates. This doesn't make sense especially because the message box still stays there when the Image or Link options show up under it. Please advise on how to add a message to these types of activity posts.

  • Brian Durost

    Ok, I know where I need your help now. I took notice that the textarea name for activity is "whats-new". I had to change this because of adding javascript to @ mention members into the form itself. I'll post the entire code from that the post-form.php page below. You will see that I took out the hyphen for the text area name and used name="whatsnew".

    I took notice that the bpfb_interface.js references this on line 389
    $text = $form.find('textarea[name="whats-new"]');

    I tried changing that to "whatsnew" and message text didn't work with links and images. When I change the textarea name back to "whats-new" the message text posts just fine with links and images, however the @ mentions (i.e. adding members into discussion) function doesn't work.

    Below is the code from post-form.php so you can see what I have going on. Please let me know what I need to add or change to make this work.

    <?php
    
    /**
     * BuddyPress - Activity Post Form
     *
     * @package BuddyPress
     * @subpackage buddyboss
     */
    
    ?>
    
    <?php global $buddyboss_wall, $bp; ?>
    
    <?php if (bp_is_group() || bp_is_home() || bp_is_member() || bp_is_user_activity() || 'activity' == bp_dtheme_page_on_front()
    					|| ( is_archive() && $bp->current_component === 'activity' ) ): ?>
    
    	<?php if ( !is_user_logged_in() ) : ?>
    
    		<div id="message">
    			<p>You need to <a href="<?php echo site_url( 'wp-login.php' ) ?>">log in</a> <?php if ( bp_get_signup_allowed() ) : ?> or <?php printf( __( ' <a class="create-account" href="%s" title="Create an account">create an account</a>', 'buddypress' ), site_url( BP_REGISTER_SLUG . '/' ) ) ?><?php endif; ?> to post to this user's Wall.</p>
    		</div>
    
    	<?php elseif (!bp_is_home() && (!is_super_admin() && current_user_can('manage_options') && !buddyboss_is_admin()) && (bp_is_user() && (BUDDYBOSS_WALL_ENABLED && !$buddyboss_wall->is_friend($bp->displayed_user->id)) )):?>
    
    		<div id="message" class="info">
    			<p><?php printf( __( "You and %s are not connected. Request connection to post to their Wall.", 'buddyboss' ), bp_get_displayed_user_fullname() ) ?></p>
    		</div>
    
    	<?php else:?>
    
    		<?php if ( is_user_logged_in() ) : ?>
    
    			<?php if ( isset( $_GET['r'] ) ) : ?>
    				<div id="message" class="info">
    					<p><?php printf( __( 'You are mentioning %s in a new update, this user will be sent a notification of your message.', 'buddypress' ), bp_get_mentioned_user_display_name( $_GET['r'] ) ) ?></p>
    				</div>
    			<?php endif; ?>
    
    			<form action="<?php bp_activity_post_form_action(); ?>" method="post" id="whats-new-form" name="whatsnewform" role="complementary">
    
    			<?php do_action( 'bp_before_activity_post_form' ); ?>
    
    				<p class="activity-greeting">
    
    					<?php if ( bp_is_group() ) : ?>
    
    						<?php printf( __( "What's new in %s, %s?", 'buddypress' ), bp_get_group_name(), bp_get_user_firstname() );?>
    
    					<?php elseif ( bp_is_page( BP_ACTIVITY_SLUG ) || bp_is_my_profile() && bp_is_user_activity() ): ?>
    
    						<?php printf( __( "What's new, %s?", 'buddypress' ), bp_get_user_firstname() );?>
    
    					<?php elseif( !bp_is_my_profile() && bp_is_user_activity() ): ?>
    
    						<?php printf( __( "Write something to %s?", 'buddyboss' ), bp_get_displayed_user_fullname() ) ;?>
    
    					<?php else :?>
    
    						<?php printf( __( "Add a photo, %s", 'buddyboss' ), bp_get_user_firstname() );?>
    
    					<?php endif; ?>
    
    				</p>
    
    	<div id="whats-new-icons">
    
        <script>
    function recordDone(u,uvn,vid) {
    	sessionid = get_cookie('viddlersessionid');
    	u = get_cookie('viddlerusername');
    
      	var html = '[viddler id='+vid+']'+"\n";
    
      	var textareaboxid = $v('#viddlercommentpost').val();
    
      	var commentsofar = $v('#'+textareaboxid).val();
      	var csf = commentsofar;
      	$v('#'+textareaboxid).val(csf+"\n"+html);
    
      	var earl = $v('#viddlerposturl').val();
      	var posttitle = $v('#viddlerposttitle').val();
      	var customtags = $v('#viddlercustomtags').val();
    
      	var gw = $v('#viddlergateway').val()+'viddlergateway.php';
    	var m = 'viddler.videos.setDetails';
    	var s = 'sessionid='+sessionid+'&video_id='+vid+'&earl='+earl+'&posttitle='+posttitle+'&customtags='+customtags+'&admin=N';
    
    	$v.ajax({
    		url: gw,
    		type: 'GET',
    		data: 'm='+m+'&'+s,
    		dataType: 'text',
    		timeout: 8200,
    		error: function(){
    			$v('#facebox .content').html('The video was not saved properly. Please try again.');
    		},
    		success: function(response){
    			if (response == 'success') {
    			   $v('#facebox .content').html('<ul class="fbnavigation"><li><a class="logout" href="#logout" onclick="viddler_logout();">Logout</a></li><li><a href="#record" onclick="viddler_loadrecorder(\''+sessionid+'\');">Record</a></li><li><a href="#viddlerchoose" onclick="viddler_loadvideos(\''+sessionid+'\',\''+u+'\');">Choose</a></li></ul><h2>Video saved!</h2><p>Your video has been stored in the text box.  You may now close this window, or choose or record another video.  Thanks for commenting!</p>');
    			} else {
    				$v('#facebox .content').html('<ul class="fbnavigation"><li><a class="logout" href="#logout" onclick="viddler_logout();">Logout</a></li><li><a href="#record" onclick="viddler_loadrecorder(\''+sessionid+'\');">Record</a></li><li><a href="#viddlerchoose" onclick="viddler_loadvideos(\''+sessionid+'\',\''+u+'\');">Choose</a></li></ul><h2>Comment private?</h2><p>Your video may have been saved as private.  Please log into Viddler.com to check it.</p>');
    			}
    		}});
    
    }
    
    </script>
    
    		<?php if (BUDDYBOSS_PICS_ENABLED): ?>
    			<div id="whats-new-pic"><a href="#photos" id="bpfb_addPhotos"><?php _e( 'Photo', 'buddyboss' ); ?></a></div>
    
    		<?php endif; ?>
    		<div id="whats-new-pic-uploader"></div>
    	</div><!-- #whats-new-icons -->
    
         <?php if (!wp_is_mobile()) { ?><div style="float: right; margin-right: 20px; line-height: 100%;" id="videocomment">
    <input type="hidden" id="viddlergateway" name="viddlergateway" value="/wp-content/plugins/the-viddler-wordpress-plugin/" /><input type="hidden" id="viddlerposttitle" name="viddlerposttitle" value="" /><input type="hidden" id="viddlerposturl" name="viddlerposturl" value="" /><input type="hidden" id="viddlercommentpost" name="viddlercommentpost" value="whats-new" /><input type="hidden" id="viddlercustomtags" name="viddlercustomtags" value="'.$viddler_comment_box_id.'" /><input type="hidden" id="viddlerplayertype" name="viddlerplayertype" value="player" /><a href="#viddler" style="
      padding-left: 21px;
      font-size: 12px;
      color: #497EA8;
      font-weight: bold;
      min-height: 14px;
      line-height: 1.2;" rel="facebox">Video</a>
    </div>
    
    <?php } ?>
    
    <div style="float: right; margin-right: 20px; line-height: 100%;">
    <a href="#links" id="bpfb_addLinks" style="
      padding-left: 21px;
      font-size: 12px;
      color: #497EA8;
      font-weight: bold;
      min-height: 14px;
      line-height: 1.2;">Link</a>
    </div>
    
        <div style="float: right; margin-right: 20px; line-height: 100%;">
    <a href="/docs/create" id="bpfb_addDocuments2" style="
      padding-left: 21px;
      font-size: 12px;
      color: #497EA8;
      font-weight: bold;
      min-height: 14px;
      line-height: 1.2;">Document</a>
    </div>
    
    <div style="float: right; margin-right: 20px; line-height: 100%;">
    <a href="/wp-admin/post-new.php?post_type=incsub_event" id="bpfb_addEvent" style="
      padding-left: 21px;
      font-size: 12px;
      color: #497EA8;
      font-weight: bold;
      min-height: 14px;
      line-height: 1.2;">Event</a>
    </div>
    
    <div style="float: right; margin-right: 20px; line-height: 100%;">
    <a href="/wp-admin/post-new.php" id="bpfb_addPost" style="
      padding-left: 21px;
      font-size: 12px;
      color: #497EA8;
      font-weight: bold;
      min-height: 14px;
      line-height: 1.2;">Blog</a>
    </div>
    
                  <?php //wp_dropdown_users(array('name' => 'inputtext', 'exclude' => '1','field' => 'user_login',)); ?>
    
    <script language="javascript" type="text/javascript">
    function addtext() {
    	var newtext = document.whatsnewform.inputtext.value;
    	if (document.whatsnewform.placement[1].checked) {
    		document.whatsnewform.whatsnew.value = "";
    		}
    	document.whatsnewform.whatsnew.value += newtext;
    
    }
    </script>
    
    	<div id="whats-new-content">
    		<div id="whats-new-textarea">
    			<textarea name="whatsnew" id="whats-new" cols="50" rows="10"><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ); ?><?php endif; ?></textarea>
    
    		</div>
    
    		<div id="whats-new-options">
    			<div id="whats-new-submit">
    
                <?php do_action( 'bp_before_activity_loop' ); ?>
    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
    
       <?php $activity_count = bp_get_activity_count(); ?>
    
    <?php endif; ?>
    <?php do_action( 'bp_after_activity_loop' ); ?>
    
    <input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="<?php _e( 'Post Update', 'buddypress' ); ?>" />
    
    			</div>
    
    			<?php if ( bp_is_active( 'groups' ) && !bp_is_my_profile() && !bp_is_group() && !bp_is_user_activity() ) : ?>
    
    				<div id="whats-new-post-in-box">
    
    					<div class="whats-new-select no-ajax" id="filter">
                <ul>
                    <li id="members-order-select" class="last filter">
                        <label for="members-order-by"><?php _e( 'Post in', 'buddypress' ); ?>:</label>
                        <select id="whats-new-post-in" name="whats-new-post-in">
                            <option selected="selected" value="0"><?php _e( 'My Profile', 'buddypress' ); ?></option>
    
                            <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0' ) ) :
                                while ( bp_groups() ) : bp_the_group(); ?>
    
                                    <option value="<?php bp_group_id(); ?>"><?php bp_group_name(); ?></option>
    
                                <?php endwhile;
                            endif; ?>
    
                        </select>
                    </li>
                </ul>
    
    	        </div> <!-- /.whats-new-select -->
    				</div> <!-- /.whats-new-post-in-box -->
    
    				<input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    
    			<?php elseif ( bp_is_group_home() ) : ?>
    
    				<input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    				<input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" />
    
    			<?php endif; ?>
    
    			<?php do_action( 'bp_activity_post_form_options' ); ?>
    
    		</div><!-- #whats-new-options -->
    
    		<div class="clearfix" id="whats-new-pic-preview">
    			<div class="clearfix" id="whats-new-pic-preview-inner"></div>
    		</div><!-- #whats-new-pic-preview -->
    
    	</div><!-- #whats-new-content -->
    
    	<?php wp_nonce_field( 'post_update', '_wpnonce_post_update' ); ?>
    	<?php do_action( 'bp_after_activity_post_form' ); ?>
    
                          <strong>Add Members to Discussion</strong><br>    
    
                           <?php $args = array(
        'exclude' => array(1),
    );
    
    $users = get_users( $args );
    
    // now make your users dropdown
    if ($users) { ?>
        <select name="inputtext">
            <?php foreach ($users as $user) {
                echo '<option value="@' .$user->user_nicename .' ">' .$user->display_name .'</option>';
            } ?>
        </select>
        <?php
    }
    
    // now get selected user id from $_POST to use in your next function
    $user_id = $_POST['inputtext'];
    
    // get user data
    $user_data = get_user_by('ID', $user_id);
    
    echo $user_data->display_name;
    echo $user_data->user_nicename;
    echo $user_data->user_email;
    
    // do your stuff using $user_id ?>
    
    <input type="radio" name="placement" value="append" checked> Include Member
    <input type="radio" name="placement" value="replace"> Replace Members
    
    <input type="button" value="Add Member" onClick="addtext();">
    
    </form><!-- #whats-new-form -->
    
    		<?php else : ?>
    
    			<div id="message" class="info">
    				<p>You need to <a href="<?php echo site_url( 'wp-login.php' ) ?>">log in</a> <?php if ( bp_get_signup_allowed() ) : ?> or <?php printf( __( ' <a class="create-account" href="%s" title="Create an account">create an account</a>', 'buddypress' ), site_url( BP_REGISTER_SLUG . '/' ) ) ?><?php endif; ?> to post to this user's wall.</p>
    			</div>
    
    		<?php endif; ?>
    
    	<?php endif; ?>
    <?php endif; ?>
  • Ash

    Hello @Jason Verdelli

    I hope you are well today and thank you for your patience.

    The code is not understandable when the code snippet is long and posted in the forum :slight_smile:

    Would you please send me the following?
    1. Admin login
    2. Ftp login
    3. URL of the activity page (if changed)
    4. Location of the file that you edited/posted here.

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question
    Subject: Attn-Ash
    Details: Send all required details with a link of this thread, so that I can track.
    Also post a note here once you send the info.

    I will be happy to take a look :slight_smile:

    Cheers
    Ash

  • Brian Durost

    If you reference lines 302 - 338 in post-form.php you will see that I have php that uses "inputtext" to reference the javascript that I had originally. I believe this is what the javascript used to grab the user nickname and put it before the "@".

    Originally my thought was to try to change the text area name to "whatsnew" so the javascript would work. As I mentioned before, for some reason this plugin needs to have the text area name as "whats-new". Not sure why.

    Any help to get this resolved quickly will be appreciated since this isn't working right now. Thanks so much!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.