Search Results for 'code'
-
AuthorSearch Results
-
August 23, 2020 at 2:50 pm #213973
In reply to: Allow Users to Edit There Profile Icon on menu Bar
uksentinel
ParticipantIf you could explain the whole process of what I need to do, and the code needed and where it goes, then I am sure others would be interested in reading this thread ?
August 23, 2020 at 2:39 pm #213972Topic: bbPress Profile Link Shortcode Plugin
in forum Pluginsuksentinel
ParticipantThere used to be a plugin called ‘bbPress Profile Link Shortcode’ created by ‘Tyler Tervooren’
Alas this plugin is out of date, is there any equivalents ?
August 23, 2020 at 11:39 am #213964In reply to: Allow Users to Edit There Profile Icon on menu Bar
hellojesse
ParticipantCombined html with php
<a href="<?php echo bbp_get_user_profile_url( get_current_user_id() ); ?>">Profile</a>Can you share theme? I will customize it and you will just activate it 😉
August 23, 2020 at 11:30 am #213963In reply to: Allow Users to Edit There Profile Icon on menu Bar
uksentinel
ParticipantAugust 23, 2020 at 10:48 am #213959In reply to: Another user’s edit page jumps to the profile page
hellojesse
ParticipantYou do not want to give access to profile subpages to other forum participants.
Yes, you are rock.
I do not use operand
and. I like&&.Glad you like it 😊🐱😝
August 23, 2020 at 10:26 am #213958In reply to: Another user’s edit page jumps to the profile page
robertherold
ParticipantThank you very much, it was very good. I added a bit because I want the user to access their own links, but not other users.
I did it well?
add_action( 'template_redirect', 'redirect_user_to_profile_from_subpages' ); function redirect_user_to_profile_from_subpages() { global $wp; $user_id = bbp_get_displayed_user_id(); // subpage - enagements if ($wp->query_vars["bbp_engagements"] == 1 and $user_id != get_current_user_id() ) { wp_safe_redirect( bbp_get_user_profile_url( $user_id ) ); exit; } // subpage - topics created if (bbp_is_topics_created() and $user_id != get_current_user_id() ) { wp_safe_redirect( bbp_get_user_profile_url( $user_id ) ); exit; } // subpage - replies created if (bbp_is_replies_created() and $user_id != get_current_user_id() ) { wp_safe_redirect( bbp_get_user_profile_url( $user_id ) ); exit; } // subpage - subscriptions if (bbp_is_subscriptions() and $user_id != get_current_user_id() ) { wp_safe_redirect( bbp_get_user_profile_url( $user_id ) ); exit; } }August 23, 2020 at 9:55 am #213956In reply to: Looking for a feature
hellojesse
ParticipantYes, @delta5
Auto-embed links:
Embed media (YouTube, Twitter, Flickr, etc…) directly into topics and repliesGo to -> Settings -> Forums -> Forum Features (section) -> Auto-embed linksAugust 23, 2020 at 9:38 am #213954In reply to: Another user’s edit page jumps to the profile page
hellojesse
ParticipantAll right so you have above defined 4 links. 4 subpages and we want to redirect redirect them to user profile main page.
We need to use hook to redirect those pages
add_action( 'template_redirect', 'redirect_user_to_profile_from_subpages' ); function redirect_user_to_profile_from_subpages() { global $wp; // subpage - enagements if ($wp->query_vars["bbp_engagements"] == 1 ) { wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) ); exit; } // subpage - topics created if (bbp_is_topics_created()) { wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) ); exit; } // subpage - replies created if (bbp_is_replies_created()) { wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) ); exit; } // subpage - subscriptions if (bbp_is_subscriptions()) { wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) ); exit; } }Let me know if this works for you.
August 23, 2020 at 8:38 am #213947In reply to: Allow Users to Edit There Profile Icon on menu Bar
hellojesse
ParticipantSure, contact anytime. 😉
This can help as well.
We can use action hook. Here is explation how to use it. There are files where you can find the place.
https://codex.bbpress.org/bbp_theme_before_forum_title/August 23, 2020 at 8:29 am #213945In reply to: Allow Users to Edit There Profile Icon on menu Bar
hellojesse
ParticipantThis code will generate html link if you combine with code above:
<a href="[php_code]">Profile</a>Place it above the forum maybe?
August 23, 2020 at 8:28 am #213944In reply to: Allow Users to Edit There Profile Icon on menu Bar
uksentinel
ParticipantCorrect and many thanks
where should I place profile code ?
<?php echo bbp_get_user_profile_url( get_current_user_id() ); ?>
August 23, 2020 at 8:24 am #213943In reply to: Allow Users to Edit There Profile Icon on menu Bar
hellojesse
ParticipantSSo, you said you need dynamic url to user bbpress profile. Correct?
This code will generate profile url
<?php echo bbp_get_user_profile_url( get_current_user_id() ); ?>August 23, 2020 at 5:37 am #213931In reply to: Create a new forum on each new post?
hellojesse
ParticipantIt should be easy to understand code and should work as you describe above.
Do not hesitate to contact me.
Here are my screenshots:
Home Page:
https://ibb.co/8m1225XSingle Page:
https://ibb.co/KhCDFtxAugust 23, 2020 at 5:22 am #213930In reply to: Create a new forum on each new post?
hellojesse
ParticipantI would like the first forum topic created to be displayed on the post page.
You need to add another line of code to action function. We need to save topic id to post meta.
whole function.php
// Add the hook action add_action('transition_post_status', 'send_new_post', 10, 3); // Listen for publishing of a new post function send_new_post($new_status, $old_status, $post) { if('publish' === $new_status && 'publish' !== $old_status && $post->post_type === 'post') { $my_post = array( 'post_title' => $post->ID, ); $forum_id = bbp_insert_forum($my_post); $my_topic = array( 'post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_parent' => $forum_id ); $topic_id = bbp_insert_topic($my_topic); update_post_meta( $post->ID, 'forum_first_topic', $topic_id ); } }In single.php we can call your shortcode for showing topic by id because whe have post meta.
Paste this into loop:
$topic_id = get_post_meta( get_the_ID(), 'forum_first_topic', true ); echo do_shortcode(' [bbp-single-topic id='.$topic_id.']');Whole single php loop:
<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <div class="article"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <h2>Forum: <?php echo basename(get_permalink()); ?></h2> <?php $post = get_post(get_the_ID()); $mypost = get_page_by_title(get_the_ID(),OBJECT,'forum'); $topic_id = get_post_meta( get_the_ID(), 'forum_first_topic', true ); echo do_shortcode(' [bbp-single-topic id='.$topic_id.']'); echo do_shortcode( '[bbp-single-forum id='.$mypost->ID.']' ); ?> </div> <?php endwhile; ?> <?php endif; ?>August 23, 2020 at 4:18 am #213929In reply to: Create a new forum on each new post?
hellojesse
ParticipantHow do I add the post content to the first post of the new topic?
Under this action:
add_action('transition_post_status', 'send_new_post', 10, 3);Replace with updated function:
// Listen for publishing of a new post function send_new_post($new_status, $old_status, $post) { if('publish' === $new_status && 'publish' !== $old_status && $post->post_type === 'post') { $my_post = array( 'post_title' => $post->ID, ); $forum_id = bbp_insert_forum($my_post); $my_topic = array( 'post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_parent' => $forum_id ); bbp_insert_topic($my_topic); } }August 23, 2020 at 4:02 am #213928In reply to: Create a new forum on each new post?
hellojesse
ParticipantHow do I append the post post title to the forum id?
Change this
<h2>Forum: <?php echo get_the_ID(); ?></h2>
to this:<h2>Forum: <?php echo basename(get_permalink()); ?></h2>August 22, 2020 at 9:15 pm #213923In reply to: Create a new forum on each new post?
slugs
ParticipantThat works great! Thank you so much.
How do I add the post content to the first post of the new topic? I can’t work out how to target the first post with add_action().
How do I append the post post title to the forum id? It looks like this (Forum: 67) it might be better if it was post-title-67 e.g starwars-67
I would like the first forum topic created to be displayed on the post page. I currently achieve this by:
Add new block
[/] shortcode
Add the bbpress shortcode
[bbp-single-topic id=40]
The id is found when edititing the topic in the address bar https://site/wp-admin/post.php?post=40&action=edit
Is there a way of automating this task?
August 22, 2020 at 6:29 am #213911In reply to: Change vertical forum stats to horizontal line
Robin W
Moderatorthe default is horizontal – do you you have a theme, plugin or code that is changing this?
August 22, 2020 at 2:22 am #213899In reply to: Code behaving abnormally
nayanboost
ParticipantThe code is:
add_action ('template_redirect', 'forum_security'); function forum_security(){ $roles = wp_get_current_user()-> roles; if(is_singular( array( 'forum', 'topic' ) )){ if(!is_user_logged_in()){ wp_redirect('/join'); exit; }else{ if(current_user_can('administrator')){ return; }elseif(!in_array('pmpro_role_1', $roles)){ wp_redirect('/product/channel-mcgilchrist'); exit; } } } }August 22, 2020 at 2:00 am #213898Topic: Code behaving abnormally
in forum Pluginsnayanboost
ParticipantI have written the below script to restrict users to access forums or topics. Here are the conditions:
1. If user in not logged in will be redirected to “Join” page.
2. If user is logged in but doesn’t have “pmpro_role_1” role, he will be redirected to “Product Page”.
3. If a user is the administrator, he can view the page.The problem here is for topics in forum it is working except the latest created topic. And it is taking user to “Join” page even if the user is logged in and have the “pmpro_role_1”. What is happening here?
Please help.
add_action ('template_redirect', 'forum_security'); function forum_security(){ $roles = wp_get_current_user()-> roles; if(is_singular( array( 'forum', 'topic' ) )){ if(!is_user_logged_in()){ wp_redirect('/join'); exit; }else{ if(current_user_can('administrator')){ return; }elseif(!in_array('pmpro_role_1', $roles)){ wp_redirect('/product/channel-mcgilchrist'); } } } }August 21, 2020 at 4:35 pm #213897In reply to: Create a new forum on each new post?
slugs
ParticipantYes, thank you a simple theme to demonstrate will be fine. I’m not too sure how to use hooks and I get very confused with how to use short codes and php together.
August 21, 2020 at 6:50 am #213893In reply to: Strip all html tags forms
Robin W
ModeratorPut 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
add_filter( 'bbp_new_topic_pre_content', 'rew_strip_tags' ); add_filter('bbp_edit_topic_pre_content', 'rew_strip_tags' ); add_filter( 'bbp_new_reply_pre_content', 'rew_strip_tags' ); add_filter('bbp_edit_reply_pre_content', 'rew_strip_tags' ); function rew_strip_tags ($content) { $content = strip_tags($content); return $content ; }August 20, 2020 at 7:34 pm #213885In reply to: Create a new forum on each new post?
slugs
ParticipantHi @egyptimhotep,
Yes please, could you provide code?
I wasn’t sure how to contact you on slack? There are a eight people with the handle @Jesse.
Thanks,
Slugs
August 20, 2020 at 6:06 pm #213880In reply to: Create a new forum on each new post?
hellojesse
ParticipantI can help, you need to use hooks. If post is created, create a forum like post id of movie review. Then call shortcode with dynamic id of ppost form which is same as pos id of review.
If you need code, contact me.
August 20, 2020 at 5:46 pm #213877In reply to: Image at left of forum
hellojesse
Participant<img src="img.jpg" style="float:left;"> -
AuthorSearch Results