Hide the form if registration is not allowed
-
Greg, I try to hide the form when registration is disabled or users are not logged in. You recommended here to use a membership plugin, but another plugin for this probably is too much. I found this in the shortcode.php file for the [adverts_manage] shortcode:
if(!get_current_user_id()) { ... $permalink = get_permalink(); $message = __('Only logged in users can access this page. <a href="%1$s">Login</a> or <a href="%2$s">Register</a>.', "adverts"); $parsed = sprintf($message, wp_login_url( $permalink ), wp_registration_url( $permalink ) ); adverts_flash( array( "error" => array( $parsed ) ) ); ... }
Can be added something like this also for the [adverts_add] shortcode?
I tried to adapt this snippet to hide/unset the form when registration is disabled or user is not logged in, but without success. Can the form be hided in this way?
if ( !get_option( 'users_can_register' ) || !get_current_user_id() ) { if($field['name'] == '_adverts_account') { unset($form['field'][$k]); $permalink = get_permalink(); $message = __('Attention! Only logged in users can add adverts. <a href="%1$s">Login</a> or <a href="%2$s">Register</a>.', "adverts"); $parsed = sprintf($message, wp_login_url( $permalink ), wp_registration_url( $permalink ) ); adverts_flash( array( "error" => array( $parsed ) ) ); } // A CODE THAT WILL HIDE/UNSET THE FORM HERE ??? }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Hide the form if registration is not allowed’ is closed to new replies.