I want a link in the form to an image in the frontpage, that direct the user that is logged to the subscription packages that are on its profile:
The link look like this: /?screen=acc_pay
But I want for the user part /admin/ to change depending on the user that is logged.
I am using KingComposer:
This is the page were the link should be
And this is were it should lead undependant of the user that is logged in, so I need a customized link that leads to the author page of the user that is logged
This is the result of imputing this code
<?php
$author_page = is_user_logged_in() ? get_author_posts_url( get_current_user_id() ) : NULL;
$acc_pay_page = $author_page ? add_query_arg( 'screen', 'acc_pay', $author_page ) : NULL;
if ( $acc_pay_page) {
echo '<a href="' . esc_url( $acc_pay_page ) .'"><img src=".png" /></a>';
} else {
echo '<span>Please log in</span>';
}
?>
I want a link in the form to an image in the frontpage, that direct the user that is logged to the subscription packages that are on its profile:
The link look like this: https://mywebsite.co.uk/author/admin/?screen=acc_pay
But I want for the user part /admin/ to change depending on the user that is logged.
I am using KingComposer:
This is the page were the link should be
And this is were it should lead undependant of the user that is logged in, so I need a customized link that leads to the author page of the user that is logged
This is the result of imputing this code
<?php
$author_page = is_user_logged_in() ? get_author_posts_url( get_current_user_id() ) : NULL;
$acc_pay_page = $author_page ? add_query_arg( 'screen', 'acc_pay', $author_page ) : NULL;
if ( $acc_pay_page) {
echo '<a href="' . esc_url( $acc_pay_page ) .'"><img src="https://mywebsite.co.uk/wp-content/uploads/2020/10/pricing-06.png" /></a>';
} else {
echo '<span>Please log in</span>';
}
?>
Share
Improve this question
edited Oct 16, 2020 at 12:02
Ramdo47
31 bronze badge
asked Oct 14, 2020 at 14:52
Ramdo47Ramdo47
11 bronze badge
1 Answer
Reset to default 0You said that KingComposer will accept PHP blocks.
This will generate a link to the current logged-in user's author page:
<?php
$author_page = is_user_logged_in() ? get_author_posts_url( get_current_user_id() ) : NULL;
$acc_pay_page = $author_page ? add_query_arg( 'screen', 'acc_pay', $author_page ) : NULL;
if ( $acc_pay_page) {
echo '<a href="' . esc_url( $acc_pay_page ) .'"><img src="account_page_page.png" /></a>';
} else {
echo '<span>Please log in</span>';
}
?>