elitaz
Forum Replies Created
Viewing 6 replies - 1 through 6 (of 6 total)
-
Forum: Developing with WordPress
In reply to: One comment per post and only repliesBack to my question, if someone looking to allow only one comment per user per post I think I found a solution:
add_filter('comments_open', 'restrict_users', 10, 2); function restrict_users($open, $post_id) { if (intval($post_id) && get_post($post_id)) { $args = array('post_id' => $post_id, 'count' => true); $user = wp_get_current_user(); if ($user && intval($user->ID)) { // for registered users $skip = false; $ignoreTheseRoles = array('administrator', 'editor'); // which user roles should be ignored if ($user->roles && is_array($user->roles)) { foreach ($user->roles as $role) { if (in_array($role, $ignoreTheseRoles)) { $skip = true; break; } } } if (!$skip) { $args['user_id'] = $user->ID; $open = get_comments($args) ? false : true; } } else { // for guests $commenter = wp_get_current_commenter(); if ($commenter && is_array($commenter) && isset($commenter['comment_author_email'])) { $args['author_email'] = $commenter['comment_author_email']; $open = get_comments($args) ? false : true; } } } return $open; }
Now just need the way to let author to reply the comments…
Forum: Developing with WordPress
In reply to: One comment per post and only repliesI was able to disable post author to post comment, but now he is not able to write reply any more as well….
global $current_user; $args = array('user_id' => $current_user->ID); if ( get_current_user_id() == $post->post_author ){ echo 'disabled'; } else { comment_form( array( 'logged_in_as' => null, 'title_reply' => esc_html__( 'Leave a comment', 'twentytwentyone' ), 'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">', 'title_reply_after' => '</h2>', ) ); }
Forum: Developing with WordPress
In reply to: Reply to commentHi Ian. Thanks for reply. It works like a charm.
Cheers mate!Forum: Plugins
In reply to: [GEO my WP] All check ins on mapHi @ninjew,
Yes.Forum: Plugins
In reply to: [GEO my WP] All check ins on mapHi. Thanks for the reply. One more question, is it possible to show one member posts on the map without search? Like sort posts by user id? Thanks
Forum: Plugins
In reply to: [Travelers' Map] Map by members idAnd one more thing, is it any way to add post location via front end? For example while using Wp User frontend plugin. Thanks
Viewing 6 replies - 1 through 6 (of 6 total)