Changeset 5657
- Timestamp:
- 07/12/2017 02:43:36 AM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
r5639 r5657 51 51 52 52 /** 53 * Check "Notify me of follow-up replies via email" checkbox for new topics by default. 53 * Check "Notify me of follow-up replies via email" box for new topics by default. 54 * 55 * If the user has enabled "Always notify me via email of follow-up posts" option 56 * in their profile, check the box for new replies as well. 54 57 * 55 58 * @param string $checked Checked value of topic subscription. … … 57 60 */ 58 61 public function check_topic_subscription_checkbox( $checked ) { 59 if ( bbp_is_single_forum() || bbp_is_single_view() ) { 62 if ( 63 bbp_is_single_forum() || bbp_is_single_view() 64 || 65 get_user_option( 'auto_topic_subscription' ) 66 ) { 60 67 $checked = checked( true, true, false ); 61 68 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
r5636 r5657 6 6 7 7 public function __construct() { 8 // Add a Custom Title input to user's profile. 9 add_action( 'bbp_user_edit_after_name', array( $this, 'add_custom_title_input' ) ); 10 11 // Save Custom Title input value. 12 add_action( 'personal_options_update', array( $this, 'save_custom_title' ), 10, 2 ); 13 add_action( 'edit_user_profile_update', array( $this, 'save_custom_title' ), 10, 2 ); 8 // Add custom fields to user's profile. 9 add_action( 'bbp_user_edit_after_name', array( $this, 'add_custom_title_input' ) ); 10 add_action( 'bbp_user_edit_after', array( $this, 'add_auto_topic_subscription_checkbox' ) ); 11 12 // Save custom field values. 13 add_action( 'personal_options_update', array( $this, 'save_custom_fields' ), 10, 2 ); 14 add_action( 'edit_user_profile_update', array( $this, 'save_custom_fields' ), 10, 2 ); 14 15 15 16 // Custom user contact methods. 16 add_filter( 'user_contactmethods', array( $this, 'custom_contact_methods' ) );17 add_filter( 'user_contactmethods', array( $this, 'custom_contact_methods' ) ); 17 18 18 19 // Only allow 3 published topics from a user in the first 24 hours. 19 add_action( 'bbp_new_topic_pre_insert', array( $this, 'limit_new_user_topics' ) );20 add_action( 'bbp_new_topic_pre_insert', array( $this, 'limit_new_user_topics' ) ); 20 21 21 22 // Add query vars and rewrite rules for user's topic and review queries. 22 add_filter( 'query_vars', array( $this, 'add_query_vars' ) );23 add_action( 'bbp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ) );23 add_filter( 'query_vars', array( $this, 'add_query_vars' ) ); 24 add_action( 'bbp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ) ); 24 25 25 26 // Parse user's topic and review queries. … … 57 58 } 58 59 60 $title = get_user_option( 'title', bbp_get_displayed_user_id() ); 59 61 ?> 60 62 <div> 61 63 <label for="title"><?php esc_html_e( 'Custom Title', 'wporg-forums' ); ?></label> 62 <input type="text" name="title" id="title" value="<?php echo esc_attr( get_user_option( 'title', bbpress()->displayed_user->ID )); ?>" class="regular-text" />64 <input type="text" name="title" id="title" value="<?php echo esc_attr( $title ); ?>" class="regular-text" /> 63 65 </div> 64 <?php 65 } 66 67 /** 68 * Save Custom Title input value. 66 <?php 67 } 68 69 /** 70 * Add an auto topic subscription checkbox to user's profile. 71 */ 72 public function add_auto_topic_subscription_checkbox() { 73 $auto_topic_subscription = get_user_option( 'auto_topic_subscription', bbp_get_displayed_user_id() ); 74 ?> 75 <p> 76 <input name="auto_topic_subscription" id="auto_topic_subscription" type="checkbox" value="yes" <?php checked( $auto_topic_subscription ); ?> /> 77 <label for="auto_topic_subscription"><?php esc_html_e( 'Always notify me via email of follow-up posts in any topics I reply to', 'wporg-forums' ); ?></label> 78 </p> 79 <?php 80 } 81 82 /** 83 * Save custom field values. 69 84 * 70 85 * @param int $user_id The user ID. 71 86 */ 72 public function save_custom_title( $user_id ) { 73 if ( ! current_user_can( 'moderate' ) || ! isset( $_POST['title'] ) ) { 74 return; 75 } 76 77 update_user_option( $user_id, 'title', sanitize_text_field( $_POST['title'] ) ); 87 public function save_custom_fields( $user_id ) { 88 if ( current_user_can( 'moderate' ) && isset( $_POST['title'] ) ) { 89 update_user_option( $user_id, 'title', sanitize_text_field( $_POST['title'] ) ); 90 } 91 92 $auto_topic_subscription = isset( $_POST['auto_topic_subscription'] ); 93 update_user_option( $user_id, 'auto_topic_subscription', $auto_topic_subscription ); 78 94 } 79 95
Note: See TracChangeset
for help on using the changeset viewer.