Shortcode not working
-
Hi all
Well I should qualify that title. The shortcode is fine in itself, and no doubt nothing to do with you guys at CF7 causing this issue. I am sure it’s me, but it just isn’t working after I’ve added another shortcode directly after it. Here’s the story:
I have a page which should appear with some text to non logged-in users, and then a submission form appears when the user is logged in. I used some code for this in my functions.php which looks like this:
add_shortcode( 'visitor', 'visitor_check_shortcode' ); function visitor_check_shortcode( $atts, $content = null ) { if ( ( !is_user_logged_in() && !is_null( $content ) ) || is_feed() ) return $content; return ''; } add_shortcode( 'member', 'member_check_shortcode' ); function member_check_shortcode( $atts, $content = null ) { if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) return $content; return ''; }
and then I have wrapped the appropriate text on the page with the shortcodes as follows:
[visitor]
some text that appears to non logged-in users
[/visitor][member]
some text that appears to logged-in users and this form:
[contact-form-7 id=”26″ title=”Submit your work”]
[/member]The problem is that with the [/member] shortcode in place, it disables the contact form 7 shortcode. So that it appears on the page exactly as it does above, and doesn’t display the form. If I remove the [/member] shortcode, the contact form works again. But I need the [/member] shortcode! Any ideas what I’ve done wrong?
Thanks all
Paul
- The topic ‘Shortcode not working’ is closed to new replies.