can you define what you mean by ‘reply page’ please
‘reply page’ means content-single-topic.php .
<?php bbp_topic_subscription_link(); ?>
includes> topics > template.php
function bbp_topic_subscription_link( $args = array() ) {
echo bbp_get_topic_subscription_link( $args );
}
/**
* Get the topic subscription link
*
* A custom wrapper for bbp_get_user_subscribe_link()
*
* @since 2.5.0 bbPress (r5156)
* @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
*/
function bbp_get_topic_subscription_link( $args = array() ) {
// Defaults
$retval = false;
$user_id = bbp_get_current_user_id();
$redirect_to = bbp_is_subscriptions()
? bbp_get_subscriptions_permalink( $user_id )
: '';
// Parse the arguments
$r = bbp_parse_args( $args, array(
'user_id' => $user_id,
'object_id' => bbp_get_topic_id(),
'object_type' => 'post',
'before' => ' | ',
'after' => '',
'subscribe' => esc_html__( 'Subscribe', 'bbpress' ),
'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ),
'redirect_to' => $redirect_to
), 'get_topic_subscribe_link' );
// Get the link
$retval = bbp_get_user_subscribe_link( $r );
// Filter & return
return apply_filters( 'bbp_get_topic_subscribe_link', $retval, $r, $args );
}
without getting complicated, this will work quite well
add_filter ('bbp_get_topic_subscribe_link' , 'julia_unubsribe') ;
function julia_unubsribe($retval) {
if (strpos($retval, 'Subscribe') !== FALSE) {
$retval = '' ;
}
return $retval ;
}
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
it will let someone unsubscribe from a topic, but does let them re-subscribe if they stay within that topic (so if they click by mistake, they can unclick immediately) once they leave that topic, then they can’t subscribe, and they can’t subscribe to a topic that they are not subscribed to in the first place.
Your code works quite well. How simple they are!
I tried to customize it , but I couldn’t. I couldn’t get strpos code.
Thank you for your kindness.
no problem, glad you ae fixed !
I always have hated that PHP doesn’t have a simple ‘contains’, so you have to say if the position of some text does not equal false, then it is true so the string contains the text – very silly !