-
Author
-
October 6, 2015 at 15:28 #81112
HDcms
ParticipantHello,
I am looking to do a redirect on the groups page to redirect to the membership level if the member is already in 5 groupsThis does not work and after a few hours I realized that is_page condition does not work in the child theme functions.php
Do you have an idea ?
if (is_page(10) AND (bp_get_total_group_count_for_user($user_id) >5) ) { //
echo ‘<h2>PAGE 10</h2>’;
wp_redirect(pmpro_url(“levels”));
exit;
}Regards
October 8, 2015 at 01:06 #81406Laura
ModeratorHello, will assign the ticket to a higher support lever who can help and advise you in your query.
Thanks! 🙂Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
October 14, 2015 at 00:35 #82156HDcms
ParticipantHi,
It does not work :COPY CODEglobal $post; $p = $post->ID; echo '<br>$p: ' .$p; $Getid = get_the_ID(); echo '<br>Getid: ' .$Getid;
It work:
COPY CODE$url = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); $ID = url_to_postid($url[0]); echo '$ID: ' .$ID;
but not:
COPY CODEif ( is_page($ID) ) { echo '$ID: ' .$ID; echo '<h2>PAGE 10</h2>'; //wp_redirect(pmpro_url("levels")); //exit; }
??
October 15, 2015 at 15:11 #82365Radu
ModeratorHi,
Please be sure you are adding the redirect logic in the right action hook, see here an good example
https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect#Examples
Regards
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 16, 2015 at 18:29 #82722HDcms
ParticipantHI,
Thanks for your answer.
I have done several test. It does not work
Apparently is_page does not work in the child theme function.php !?COPY CODEfunction my_page_template_redirect() { if (is_page(10)) // is_page('groupes') { // wp_redirect( home_url( '/inscription/' ) ); // wp_redirect('http://127.0.0.1/wordpress/wp_test/inscription/' ); echo '<h2>PAGE 10</h2>'; // exit(); } } add_action( 'template_redirect', 'my_page_template_redirect' );
October 19, 2015 at 16:05 #83153Radu
ModeratorHi,
It works for me
COPY CODEfunction my_page_template_redirect() { if (is_page('groups')) { wp_redirect( home_url( '/testtheredirect/' ) ); } } add_action( 'template_redirect', 'my_page_template_redirect' );
Make sure the child theme is installed and activated
Regards
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
You must be logged in to reply to this topic.