Filters

Add registration form fields to Discussion Board

You can use the ctdb_registration_form_fields filter to add fields to your registration form. Below is an example of how this is done.

function rf_ctdb_registration_form_fields( $form ) {
  $form['ctdb_user_test'] = array(
    'id' => 'ctdb_user_test',
    'label' => __( 'Test', 'wp-discussion-board' ),
    'field' => 'input',
    'type' => 'text',
    'class' => 'required',
    'meta_key' => 'test_meta_key'
  );
  return $form;
}
add_filter( 'ctdb_registration_form_fields', 'rf_ctdb_registration_form_fields' );

You should:

  • Ensure the element key and id match.
  • Change the label to your field label
  • field should be ‘input’
  • type should be ‘text’
  • class should be ‘required’ if the field is required
  • meta_key is the name of the meta key where you’d like to field value to be saved

Filter notification of new comment email text to followers

If you have Board Following enabled, you can filter the text of the email that is sent to followers whenever a new topic is posted on a board.

In your functions.php file, or other suitable place, add the following:

/**
 * Filter the notification email text for new comments to followers of a board
 * @param $content - the original email content
 * @param $post - the post object for the new topic
 * @board_id - the ID of the board posted on
 */
function your_prefix_notification_new_comment_content( $content, $post, $comment ) {
  // Add your new message content here
  $content = 'My new message';
  return $content;
}
add_filter( 'ctdb_follower_notification_new_comment_email', 'your_prefix_notification_new_comment_content', 10, 3 );

Filter notification of new topic email text to followers

If you have Board Following enabled, you can filter the text of the email that is sent to followers whenever a new topic is posted on a board.

In your functions.php file, or other suitable place, add the following:

/**
 * Filter the notification email text to followers of a board
 * @param $message - the original email content
 * @param $post - the post object for the new topic
 * @board_id - the ID of the board posted on
 */
function your_prefix_notification_email_content( $message, $post, $board_id ) {
  // Add your new message content here
  $message = 'My new message';
  return $message;
}
add_filter( 'ctdb_follower_notification_new_topic_email', 'your_prefix_notification_email_content', 10, 3 );

Filter permitted file types for uploading

By default, only certain image file types can be uploaded in the Pro version. You can filter these file types – but please be aware that there is a security risk with allowing users to upload files.

// Add PDF to permitted file types
function prefix_filter_mime_types( $mimes ) {
  $mimes['pdf'] = 'application/pdf';
  return $mimes;
}
add_filter( 'ctdb_existing_mimes', 'prefix_filter_mime_types' );

Filter new comment subject line

function prefix_filter_email_subject( $subject ) {
  // Add your new subject line here
  return __( 'My new subject line', 'text-domain' );
}
add_filter( 'ctdb_filter_new_comment_subject', 'prefix_filter_email_subject' );

Filter moderate new comment subject line

function prefix_filter_moderate_email_subject( $subject ) {
  // Add your new subject line here
  return __( 'My new subject line', 'text-domain' );
}
add_filter( 'ctdb_filter_moderate_new_comment_subject', 'prefix_filter_moderate_email_subject' );

Filter new topic email subject line

function prefix_filter_new_topic_subject( $subject ) {
  // Add your new subject line here
  return __( 'My new subject line', 'text-domain' );
}
add_filter( 'ctdb_filter_new_topic_subject', 'prefix_filter_new_topic_subject' );

Filter account activation email subject line

function prefix_filter_activation_subject( $subject ) {
  // Add your new subject line here
  return __( 'My new subject line', 'text-domain' );
}
add_filter( 'ctdb_filter_activation_email_subject', 'prefix_filter_activation_subject' );