php - Require user login to submit form -


how can require user logged in, in order submit input?

i found piece of code, not sure how can modify suit needs:

add_action('login_head','ref_access');  function ref_access() {      global $error;      if( !empty($_get['ref']) && 'access' == $_get['ref'] )         $error  = 'restricted area, please login continue.'; } 

this input posted mysql database.

this input code stands in plugin:

<input type="text" maxlength="4" name="' . $quanid . '" value="" class="input" /> 

as of right now, can submit this, regardless of login status.

you can use wordpress's built in function that: is_user_logged_in().

example:

function ref_access() {      global $error;      if (is_user_logged_in()) {         // process form here.      }else {          $error = "hey, out of here";          return ;      } } 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -