Forum Replies Created
Viewing 1 replies (of 1 total)
-
In reply to: disable email Email (required) config ?
I have eliminated the need to enter my email address by doing the following
function bbp_set_default_email( $post_author_email ) { if ( empty( $post_author_email ) ) { $post_author_email = 'anonymous@example.com'; } return $post_author_email; } add_filter( 'bbp_pre_anonymous_post_author_email', 'bbp_set_default_email', 10, 1 ); function bbp_remove_default_email( $r, $args ) { if ( $r['bbp_anonymous_email'] == 'anonymous@example.com' ) { $r['bbp_anonymous_email'] = ''; } return $r; } add_filter( 'bbp_filter_anonymous_post_data', 'bbp_remove_default_email', 10, 2 );First, use the filter hook “bbp_pre_anonymous_post_author_email” to set the default email address if the email address is blank.
This avoids the “Invalid email address.” error.Second, if the return value “$r[‘bbp_anonymous_email’]” is set to the email address set earlier, return it blank.
This way, if an email address is entered, its value is returned, if it is blank, it is returned blank.
Viewing 1 replies (of 1 total)