Hello,
I selected the “Question must be manually approved” option in Settings->General.
It works (Admin gets an email and question isn’t posted).
However, After the user posts the question, an error is printed (twice):
Trying to get property of non-object in …/dw-question-answer/inc/User.php line 152.
This corresponds to code where the global $post variable is trying to be accessed.
- Any ideas why this is causing a problem?
- How can I forward the user to a different page while his question is being approved (eg: to the home page instead of the question post page that it currently goes to) maybe with a request parameter so I can display a small alert at the top of the page that his question is being moderated?
Thank you.
Hi,
1. You can replace with the code below.
if ( isset( $post->ID ) && ( 'dwqa-answer' == $post->post_type || 'dwqa-question' == $post->post_type ) ) {
2. You can add the code below to under the line 444 at wp-content/plugins/dw-question-answer/inc/Handle.php
wp_safe_redirect( 'your link' )
Thank you.
1) Is there a way to overwrite the User.php like we did with Handle.php?
2) Is it ok not to call “exit” after I cal wp_safe_redirect?
The documentation (https://codex.wordpress.org/Function_Reference/wp_safe_redirect) says that “exit” should almost always be called after wp_safe_redirect().
Hi,
1. Which functions in User.php you want to override?
2. Don’t worry about it. It still works fine.
1. dwqa_the_author()
2. OK.
Thanks.
Hi,
Please add the code below to wp-content/themes/your-theme-folder/functions.php
remove_filter( 'the_author', 'dwqa_the_author' ); add_filter( 'the_auhtor', 'dwqa_theme_the_author', 99 ); function dwqa_theme_the_author( $display_name ) { // your code here :) }
Please login or Register to submit your answer