This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_ap_activity_actions( $actions ) { | |
$actions['new_q']['verb'] = 'A question was asked'; | |
return $actions; | |
} | |
add_filter( 'ap_activity_actions', 'my_ap_activity_actions' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Save a upload field. | |
*/ | |
function my_save_pdf_uploads( $post_id ) { | |
$field = $form->find('pdf'); | |
$field->save_uploads(); | |
foreach( $field->uploaded_files as $filename => $id ) { | |
update_post_meta( $post_id, 'my_custom_pdf', $id ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#anspress .ap-category-item .ap-cat-img-c .ap-category-icon{ | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$form = anspress()->get_form( 'question' ); | |
$values = array( | |
'post_title' => 'Question title goes here', | |
'post_content' => 'Question description goes here', | |
'is_private' => false, // True if not private. | |
'category' => 5, // Id of taxonomy term. | |
'tags' => array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Make sure post is inserted. | |
if ( ! is_wp_error( $post_id ) ) { | |
$form = anspress()->get_form( 'question' ); | |
$values = $form->get_values(); | |
$qameta = array( | |
'last_updated' => current_time( 'mysql' ), // When last question was active. | |
'answers' => ap_count_published_answers( $post_id ), // numbers of answers. | |
'anonymous_name' => sanitize_text_field( $values['anonymous_name']['value'] ), // Anonymous user name. | |
'selected' => false, // Answer id if have a selected answer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
AP_Form_Hooks::submit_question_form( true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get question form object. | |
$form = anspress()->get_form( 'question' ); | |
// Values. | |
$values = array( | |
'post_title' => 'Question title goes here', | |
'post_content' => 'Question description goes here', | |
'is_private' => false, // True if not private. | |
'category' => 5, // Id of taxonomy term. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_ap_the_title( $title, $ID ) { | |
$post = ap_get_post( $ID ); | |
if ( 'question' === $post->post_type && ! empty( ap_selected_answer( $ID ) ) ) { | |
return $title . ' [solved]'; | |
} | |
} | |
add_filter( 'the_title', 'my_ap_the_title', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This hook will make question description field optional. | |
* | |
* @param array $form Form arguments. | |
* @return array | |
*/ | |
function my_ap_make_question_description_optional( $form ) { | |
$validate = $form['fields']['post_content']['validate']; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Override ap_user_can_ask function. | |
* | |
* @param string|boolean $ret Return empty string to continue operation. | |
* @param integer $user_id | |
* @return string|false | |
*/ | |
function my_filter_ap_user_can_ask( $ret, $user_id ) { |