• hi,
    i want to show/hide fields for users that are logged in/out.
    i know i can edit the code, for example i’ve added this to modules/submit.php:

    if ( !is_user_logged_in() ) {
        return;
    }

    inside wpcf7_submit_shortcode_handler() just before return $html;

    but this will be overwritten with a new cf7 update.
    but is it the best way??

    maybe there is some short-code attribute to show/hide according to user logged or not?

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Most theme add a class like “logged-in” to the body element when logged-in user is accessing. So how about adding this style to theme’s stylesheet?

    body.logged-in input.wpcf7-submit {
        display: none;
    }

    You can change it as you like.

    Thread Starter shemesh

    (@shemesh)

    nice! this css works to show the submit button only for logged users:

    input.wpcf7-submit {
        display: none;
    }
    body.logged-in input.wpcf7-submit {
        display: inline;
    }

    but…
    1) once again – if i update the theme files i will loose this functionality.
    2) what if i have several field elements, with the same class, but want to make only some of them available according to logged user? sure, i can do this by adding id, but this would make me very much coupled.

    would be nice (and easy to implement) if each cf7 field will get an option: “show only to logged users”.
    or maybe a step further: filter by permission.

    is there a way to write cf7 plugin that does that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘showing fields only to logged users’ is closed to new replies.