g28f99 (@g28f99)

Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)

  • g28f99
    Participant

    @g28f99

    Hi, Robin. I think the above goal to apply the customization only in some specified forums should be practical. For example, I do NOT want the above customization to take effects in two forums with forum id 124 and 126. Or, alternatively, I do NOT want the customization to take effects in forums with menu_order < 10.But I could not find any previous posts with codes to set the effective range among forums.
    How do you think about it? I have no idea how to integrate the following selection information into the above customization code. Could you please make a demonstration?

    
    $current_forum_id = get_forum_id();
    if $current_forum_id !==124 AND $current_forum_id !==126 
    

    g28f99
    Participant

    @g28f99

    So I shall finalize the code for others for reference use. One last optimization for this topic so that it is really powerful:
    I may set forums with “menu_order” <10 (class=”screen-reader-text”) as admin purpose forums and do not want to apply above customization setting. Can I really achieve that goal with some condition setting?


    g28f99
    Participant

    @g28f99

    Many many thanks!


    g28f99
    Participant

    @g28f99

    Thank you again!
    I also hope to add specified sentence after user personalized replies.

    
    add_action( 'bbp_theme_after_reply_content', 'new_reply_additional_fields', 10 );
    function new_reply_additional_fields() {
    $new_reply_additional_fields = 'Above is my personal opinion';
    	echo "<p id='new_reply_additional_fields'><font color=red font size='4pt'>$new_reply_additional_fields</p>";	
    

    Using above code directly also induce wordpress website error. To permanently show above sentence after every reply, I suppose it should be saved into metabox. Could you please help manage how to integrated into above code to solve this problem?


    g28f99
    Participant

    @g28f99

    I know you made some update.
    But, I just can not found where has been modified. Could you tell me?


    g28f99
    Participant

    @g28f99

    Great Robin! It now works well!


    g28f99
    Participant

    @g28f99

    Thanks!
    When one selection box, works well.
    When two as above, will have errors at loading website.


    g28f99
    Participant

    @g28f99

    But I found a new problem. I hope more than one selection box will be shown there.
    And there will be errors. Could you please kindly suggest solutions?

    
    add_action( 'bbp_theme_before_reply_form_content', 'rew_additional_field' );
    function rew_additional_field($post){
    	?>
    	<select name="rew_additional_field" id="rew_additional_field">
    		<option value="enqury">Enquiry</option>
    		<option value="complaint">Complaint</option>
    		<option value="feedback">Feedback</option>
    	</select>
    	
    	
    	<select name="rew_additional_field_2" id="rew_additional_field_2">
    		<option value="enqury2">Enquiry2</option>
    		<option value="complaint2">Complaint2</option>
    		<option value="feedback2">Feedback2</option>
    	</select>
    	<?php
    }
     
    
    add_action('bbp_new_reply_post_extras', 'rew_save_additional_field');
    
    function rew_save_additional_field($reply_id){ 
        global $post;
        if(isset($_POST["rew_additional_field"])) {
            update_post_meta ($reply_id, 'rew_additional_field', $_POST["rew_additional_field"]) ;
    		
        if(isset($_POST["rew_additional_field_2"])) {
            update_post_meta ($reply_id, 'rew_additional_field_2', $_POST["rew_additional_field_2"]) ;
    	}
    }
    
    add_action('bbp_theme_before_reply_content', 'rew_show_additional_field');
    
    function rew_show_additional_field () {
    $reply_id = bbp_get_reply_id();
      $field = get_post_meta($reply_id, 'rew_additional_field', true);
      if (!empty ($field)) {
    	echo "Type: ". ucfirst($field)."<br>";  
    	
      $field_2 = get_post_meta($reply_id, 'rew_additional_field_2', true);
      if (!empty ($field_2)) {
    	echo "Type: ". ucfirst($field_2)."<br>";  
      }
    }
    
    

    g28f99
    Participant

    @g28f99

    Great!Thanks a lot.


    g28f99
    Participant

    @g28f99

    I have tested it and no progress observed. How to save and demonstrate the selected option have not been properly resolved.


    g28f99
    Participant

    @g28f99

    Thank you, Robin!
    I made some corrections and further checked the selection option parts accordingly. I also add a show contents part referring to a workable previous post with link.
    The code can provide options for the user to selection. But the selection result could not be shown. I am not sure whether the selection result was added into metabox properly because I can not use the debug function. And another problem is that the “Field 1 ” was inserted into all previous replies.
    Could you further provide help to solve this problem?

    
    add_action( 'bbp_theme_before_reply_form_content', 'so_additional_content' );
    function so_additional_content($post){
    	$reply_id = bbp_get_reply_id();
        $meta_element_class = get_post_meta($reply_id, 'custom_element_grid_class_meta_box', true); //true ensures you get just one value instead of an array
        ?>   
        echo '<label>Choose the size of the element :  </label>
    
        <select name="custom_element_grid_class" id="custom_element_grid_class">
          <option value="normal" <?php selected( $meta_element_class, 'normal' ); ?>>normal</option>
          <option value="square" <?php selected( $meta_element_class, 'square' ); ?>>square</option>
          <option value="wide" <?php selected( $meta_element_class, 'wide' ); ?>>wide</option>
          <option value="tall" <?php selected( $meta_element_class, 'tall' ); ?>>tall</option>
        </select>'
        <?php
    }
     
    
     
    add_action('bbp_new_reply_post_extras', 'so_save_metabox');
    
    function so_save_metabox(){ 
        global $post;
        if(isset($_POST["custom_element_grid_class"])) {
             //check the capability: if ( !current_user_can( 'edit_post', $post->ID ))  return $post->ID;
            $meta_element_class = $_POST['custom_element_grid_class'];
            //END OF UPDATE
    
            update_post_meta($reply_id, 'custom_element_grid_class_meta_box', $meta_element_class);
            //print_r($_POST);
    		
        }
    }
    
    add_action('bbp_theme_before_reply_content', 'so_show_metabox');
    
    function so_show_metabox() {
      $meta_element_class = get_post_meta($reply_id, 'custom_element_grid_class_meta_box', true);
      // the problem is "Field 1" appear in every reply post
      echo "Field 1: ". $meta_element_class."<br>";  
    }
    
    

    g28f99
    Participant

    @g28f99

    Thanks for your kind reply, Robin!
    For the first problem, I think I can write a simple plugin with an action to solve it.
    For the second, maybe some Javascript techniques will be used.


    g28f99
    Participant

    @g28f99

    please check below for links to the related area:
    new topic area
    new reply area

Viewing 13 replies - 1 through 13 (of 13 total)