How to add wpDiscuz...
 
Notifications
Clear all

How to add wpDiscuz comments on author page

5 Posts
2 Users
0 Likes
1,725 Views
(@amjadkhalil)
New Member
Joined: 5 years ago
Posts: 2
Topic starter  

Hello

I did write a filter to activate wp comments on author page but the problem is only wp native comments which follow with,it is not hooked with wpDiscuz comments.

Is there addon or filters that i can use or buy to solve the issue.

 

Thanks


   
Quote
Topic Tags
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5872
 

Hi @amjadkhalil,

Please provide us the code you've used for this purpose. 


   
ReplyQuote
(@amjadkhalil)
New Member
Joined: 5 years ago
Posts: 2
Topic starter  

Hello

Thanks for fast feedback.

I did write the code on author.php,and functions.php

 

On author.php

<?php



$profile_page = get_the_author_meta('user_profile_page');

global $post;
$post = get_post($profile_page);

setup_postdata( $post );

//fool wordpress to think we are on a single post page
$wp_query->is_single = true;
//get comments
comments_template();
//reset wordpress to ture post
$wp_query->is_single = false;

wp_reset_query();
?>


-----------------------------------------------
on function.php
function activate_comments_for_user($user_id){

$user = get_user_by( 'id', $user_id );

/**
* if required you can limit this profile creation action to some limited
* roles only
*/

/**
* Created new Page under "user_profile_page" every time a new User
* is being created
*/

$profile_page = wp_insert_post(array(
'post_title' => " $user->display_name Profile ", // Text only to Map those page @ admin
'post_type' => "user_profile_page", // Custom Post type which you have created
'post_status' => 'publish',
'post_author' => $user_id,

));

/**
* Save the Profile Page id into the user meta
*/
if(!is_wp_error($profile_page))
add_user_meta($user_id,'user_profile_page',$profile_page,TRUE);
}

/**
* Action which is being trigger Every time when a new User is being created
*/
add_action('user_register','activate_comments_for_user');

   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5872
 

ok @amjadkhalil

I'll ask developers and let you know asap. 


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5872
 

@amjadkhalil,

We've added a new line in wp_insert_post function: 

'comment_status' => 'open',

Please try it:

$profile_page = wp_insert_post(array(
'post_title' => " $user->display_name Profile ", // Text only to Map those page @ admin
'post_type' => "user_profile_page", // Custom Post type which you have created
'post_status' => 'publish',
'post_author' => $user_id,
'comment_status' => 'open',

));

Also please make sure the "Display comment form for post types" is enabled for the current post type. 

More info here: https://wpdiscuz.com/docs/wpdiscuz-documentation/getting-started/custom-comment-form/comment-form-settings/#post-types


   
ReplyQuote
Share:
Scroll to top