I want to make a PHP Shortcode
-
Hi there! I am using wordpress, and I am unable to use php codes in my pages.
Somewhere I found that using shortcodes, one can use php code anywhere.
Please let me know how can I do it.
I followed many guides, did some work in functions.php too, but still it shows Error 500.Please let me know, my php code –
// Add Shortcode function custom_shortcode_logincall() { <?php global $current_user; $second_website_url = 'https://secondwebsite.com'; // put your second website url $user_email = $current_user->user_email; $user_login = $current_user->user_login; if($user_email != ''){ $email_encoded = rtrim(strtr(base64_encode($user_email), '+/', '-_'), '='); //email encryption $user_login_encoded = rtrim(strtr(base64_encode($user_login), '+/', '-_'), '='); //username encryption echo '<a href="'.$second_website_url.'/sso.php?key='.$email_encoded.'&detail='.$user_login_encoded.'" target="_blank" rel="noopener noreferrer">Link to second website</a>'; }?> } add_shortcode( 'logincall', 'custom_shortcode_logincall' );
Any shortcode name will be appriciated!
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘I want to make a PHP Shortcode’ is closed to new replies.