{"id":3220,"date":"2018-11-13T16:45:41","date_gmt":"2018-11-13T15:45:41","guid":{"rendered":"https:\/\/www.axew3.com\/w3\/?p=3220"},"modified":"2024-05-28T13:06:16","modified_gmt":"2024-05-28T11:06:16","slug":"add-recaptcha-to-memberpress-login-page","status":"publish","type":"post","link":"https:\/\/www.axew3.com\/w3\/2018\/11\/add-recaptcha-to-memberpress-login-page\/","title":{"rendered":"Add google recaptcha to memberpress login page"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I&#8217;ve come across to a problem for a site i&#8217;m following: they use <strong><a href=\"https:\/\/memberpress.com\/\" target=\"_blank\" rel=\"noopener\">memberpress<\/a> login page<\/strong>, that unfortunately present a lack about brute force attacks: there is no way to add a <em><strong>google recaptcha<\/strong><\/em> so easily.<br>Since i had to resolve in short this issue, and since i use a simple google recaptcha plugin here at axew3.com to prevent robot&#8217;s fake registrations, i edited the code just a little two lines making it work also into memberpress. The explained trick could be easily done using any other recaptcha plugin, but this 156 lines plugin, can also be easily <em>hacked<\/em> for our scope and will do the simple dirty job.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Download this plugin and install and configure it<\/strong> (or as you like, may download the plugin, apply modifications as below indicated, then upload into your plugin directory and install)<strong>:<\/strong><br><a href=\"https:\/\/wordpress.org\/plugins\/simple-google-recaptcha\/\" target=\"_blank\" rel=\"noopener\">Simple Google reCAPTCHA<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>open the file<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>\/wp-content\/plugins\/simple-google-recaptcha\/<strong>simple-google-recaptcha.php<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>on it search for this line:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function sgr_check() {<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>just after add the follow:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if( isset($_REQUEST&#91;'mepr_process_login_form']) &amp;&amp; isset($_REQUEST&#91;'mepr_is_login_page']) ){\n\tsgr_verify($_REQUEST);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>then search for:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">add_action(\"init\", \"sgr_check\");<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>change into:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">add_action(\"init\", \"sgr_check\", 9);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">save and replace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Now open:<\/strong><br><em>\/wp-content\/plugins\/memberpress\/app\/views\/login\/<strong>form.php<\/strong><\/em><br><strong>and immediately after this:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;div&gt;\n        &lt;label&gt;&lt;input name=\"rememberme\" type=\"checkbox\" id=\"rememberme\" value=\"forever\"&lt;?php checked(isset($_REQUEST&#91;'rememberme'])); ?&gt; \/&gt; &lt;?php _ex('Remember Me', 'ui', 'memberpress'); ?&gt;&lt;\/label&gt;\n      &lt;\/div&gt;\n      &lt;div class=\"mp-spacer\"&gt;&amp;nbsp;&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>add the follow<\/strong> (note that the code could be added wherever you want, but before the closing &lt;\/form&gt; tag):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;div class=\"sgr-recaptcha\"&gt;&lt;\/div&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save and replace. If there is some payment\/subscription process using same page to access (for example) a payment renew, then may something else need to be added to prevent action to fire when not needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cheers to all lovely and cool people!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve come across to a problem for a site i&#8217;m following: they use memberpress login page, that unfortunately present a lack about brute force attacks: there is no way to add a google recaptcha so easily.Since i had to resolve in short this issue, and since i use a simple google recaptcha plugin here at [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[143],"tags":[97,180,183,179],"class_list":["post-3220","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-how-to","tag-memberpress","tag-memberpress-google-recaptcha","tag-memberpress-login-recaptcha"],"_links":{"self":[{"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/posts\/3220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/comments?post=3220"}],"version-history":[{"count":2,"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/posts\/3220\/revisions"}],"predecessor-version":[{"id":7700,"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/posts\/3220\/revisions\/7700"}],"wp:attachment":[{"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/media?parent=3220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/categories?post=3220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.axew3.com\/w3\/wp-json\/wp\/v2\/tags?post=3220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}