Changeset 615824
- Timestamp:
- 10/22/2012 10:30:41 PM (12 years ago)
- Location:
- bp-registration-options/trunk
- Files:
-
- 9 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
bp-registration-options/trunk/bp-registration-options.php
r298940 r615824 1 1 <?php 2 //ADD BUDDYPRESS MENU ITEM FOR 'Registration Options'3 2 4 function bprwg_admin_menu() { 3 class BP_Registration_Options { 4 function __construct() { 5 // Define plugin constants 6 $this->version = BP_REGISTRATION_OPTIONS_VERSION; 7 $this->basename = plugin_basename( __FILE__ ); 8 $this->directory_path = plugin_dir_path( __FILE__ ); 9 $this->directory_url = plugins_url( 'bp-registration-options/' ); 5 10 6 if ( !is_site_admin() ) 11 register_activation_hook( __FILE__, array( $this, 'activate' ) ); // plugin activation actions 12 register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); 7 13 8 return false;9 14 10 add_submenu_page( 'bp-general-settings', __( 'Registration Options', 'bprwg'), __( 'Registration Options', 'bprwg' ), 'administrator', 'bp-registration-options', 'bprwg_admin_screen' ); 15 require_once( $this->directory_path . 'includes/admin.php' ); 16 require_once( $this->directory_path . 'includes/core.php' ); 17 } 18 19 /** 20 * Activation hook for the plugin. 21 * 22 * 23 * 24 */ 25 function activate() { 26 $this->includes(); 11 27 28 //verify user is running WP 3.0 or newer 29 if ( version_compare( get_bloginfo( 'version' ), '3.0', '<' ) ) { 30 deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate our plugin 31 wp_die( 'This plugin requires WordPress version 3.0 or higher.' ); 32 } 33 flush_rewrite_rules(); 34 } 35 36 /** 37 * Deactivation hook for the plugin. 38 * 39 * 40 * 41 */ 42 function deactivate() { 43 global $wp_rewrite; 44 flush_rewrite_rules(); 45 } 12 46 } 13 47 14 add_action( 'admin_menu', 'bprwg_admin_menu' );15 16 17 18 //ADMIN SETTINGS PAGE19 20 function bprwg_admin_screen() {21 22 global $wpdb, $bp, $iprefix;23 24 switch_to_blog(1);25 26 echo"<h2>BuddyPress Registration Options</h2>";27 28 $get_groups=get_option('bprwg_groups');29 30 $bp_groups = explode(',', $get_groups);31 32 $get_blogs=get_option('bprwg_blogs');33 34 $bp_blogs = explode(',', $get_blogs);35 36 $bp_moderate=get_option('bprwg_moderate');37 38 if($_POST['save_privacy']!=""){39 40 check_admin_referer('cro_check');41 42 $privacy_network=$_POST['privacy_network'];43 44 update_option('bprwg_privacy_network', $privacy_network);45 46 if($privacy_network){47 48 $privacy_network_exceptions=$_POST['privacy_network_exceptions'];49 50 }51 52 update_option('bprwg_privacy_network_exceptions', $privacy_network_exceptions);53 54 $privacy_profiles_limit=$_POST['privacy_profiles_limit'];55 56 update_option('bprwg_privacy_profiles_limit', $privacy_profiles_limit);57 58 $privacy_profile_views=$_POST['privacy_profile_views'];59 60 update_option('bprwg_privacy_profile_views', $privacy_profile_views);61 62 }elseif($_POST['Save']!=""){63 64 65 66 //nonce WP security check67 68 check_admin_referer('cro_check');69 70 71 72 //Save Options73 74 $bp_groups=$_POST['bp_groups'];75 76 if($bp_groups){77 78 $bp_groups_str = implode(",", $bp_groups);79 80 }81 82 update_option('bprwg_groups', $bp_groups_str);83 84 $bp_blogs=$_POST['bp_blogs'];85 86 if($bp_blogs){87 88 $bp_blogs_str = implode(",", $bp_blogs);89 90 }91 92 update_option('bprwg_blogs', $bp_blogs_str);93 94 $bp_moderate=$_POST['bp_moderate'];95 96 update_option('bprwg_moderate', $bp_moderate);97 98 $activate_message=$_POST['activate_message'];99 100 update_option('bprwg_activate_message', $activate_message);101 102 $approved_message=$_POST['approved_message'];103 104 update_option('bprwg_approved_message', $approved_message);105 106 $denied_message=$_POST['denied_message'];107 108 update_option('bprwg_denied_message', $denied_message);109 110 }111 112 if($_POST['reset_messages']!=""){113 114 delete_option('bprwg_activate_message');115 116 delete_option('bprwg_approved_message');117 118 delete_option('bprwg_denied_message');119 120 }121 122 //Menu123 124 $view=$_GET['view'];?>125 126 <a <?php if ($view==""){?>style="font-weight:bold;"<?php } ?> href="<?php echo add_query_arg ('view', '');?>">Registration Settings</a> |127 128 <a <?php if ($view=="privacy"){?>style="font-weight:bold;"<?php } ?> href="<?php echo add_query_arg ('view', 'privacy');?>">Privacy Settings</a> <!-- |129 130 <a <?php if ($view=="spam"){?>style="font-weight:bold;"<?php } ?> href="<?php echo add_query_arg ('view', 'spam');?>">Spam Settings</a> |131 132 <a <?php if ($view=="mapping"){?>style="font-weight:bold;"<?php } ?> href="<?php echo add_query_arg ('view', 'mapping');?>">WP Site/BP Group Mapping</a>-->133 134 <?php135 136 //ADMIN MODERATION ACTION*********************************************137 138 if($bp_moderate=="yes"){139 140 //Moderation Actions*******************************************141 142 if ($view=="members" && $_POST['Moderate']!=""){143 144 $moderate_action=$_POST['Moderate'];145 146 $bp_member_check=$_POST['bp_member_check'];147 148 if($moderate_action=="Approve" && $bp_member_check!=""){149 150 $groups="";151 152 foreach ($bp_groups as $value) {153 154 $groups=$groups.",".$value;155 156 }157 158 for ($i = 0; $i < count($bp_member_check); ++$i) {159 160 $userid=$bp_member_check[$i];161 162 $user_info = get_userdata($userid);163 164 $username=$user_info->user_login;165 166 $useremail=$user_info->user_email;167 168 //update any requested private groups169 170 if ($groups!=""){171 172 $group_email="";173 174 $groups="00".$groups;175 176 177 178 $db_result = $wpdb->get_results( "select a.id,a.name,b.slug from ".$iprefix."bp_groups a, ".$iprefix."bp_groups_members b where a.id=b.group_id and b.user_id=$userid and a.id in (".$groups.") and a.status in ('semi','private') and b.is_confirmed=0" );179 180 if ( count( $db_result ) > 0 ) {181 182 foreach( $db_result as $the_db_result ) {183 184 $group_id = $the_db_result->id;185 186 $group_name = $the_db_result->name;187 188 $group_slug = $the_db_result->slug;189 190 $group_radio=$_POST["usergroup_".$userid."_".$group_id];191 192 if ($group_radio=="approve"){193 194 $sql="update ".$iprefix."bp_groups_members set is_confirmed=1 where group_id=$group_id and user_id=$userid";195 196 $wpdb->query($wpdb->prepare($sql));197 198 $group_email.="You have been accepted to the group [".$group_name."] - ".get_bloginfo("url")."/groups/".$slug."/.\n\n";199 200 }elseif ($group_radio=="deny"){201 202 $sql="delete from ".$iprefix."bp_groups_members where group_id=$group_id and user_id=$userid";203 204 $wpdb->query($wpdb->prepare($sql));205 206 $group_email.="Sorry but you were not accepted to the group [".$group_name."] - ".get_bloginfo("url")."/groups/".$slug."/.\n\n";207 208 }elseif ($group_radio=="ban"){209 210 $sql="update ".$iprefix."bp_groups_members set is_banned=1 where group_id=$group_id and user_id=$userid";211 212 $wpdb->query($wpdb->prepare($sql));213 214 $group_email.="Sorry but you were not accepted to the group [".$group_name."] - ".get_bloginfo("url")."/groups/".$slug."/.\n\n";215 216 }217 218 }219 220 }221 222 }223 224 update_usermeta($userid, 'bprwg_status', 'approved');225 226 $sql="update ".$iprefix."users set deleted=0 where ID=$userid";227 228 $wpdb->query($wpdb->prepare($sql));229 230 //update bp activity231 232 $sql="update ".$iprefix."bp_activity set hide_sitewide=0 where user_id=$userid";233 234 $wpdb->query($wpdb->prepare($sql));235 236 //email member with custom message237 238 $approved_message=get_option('bprwg_approved_message');239 240 $the_email=$approved_message;241 242 $the_email=str_replace("[username]",$username,$the_email);243 244 //$the_email="Hi ".$username.",\n\nYour member account on ".get_bloginfo("url")." has been approved! You can now login and start interacting with the rest of the community...";245 246 if($group_email!=""){247 248 $the_email.="\n\nThe following information pertains to each group you requested to join:\n\n".$group_email;249 250 }251 252 wp_mail($useremail, 'Membership Approved', $the_email);253 254 }255 256 //DENY OR BAN MEMBERS257 258 }elseif($moderate_action=="Deny" && $bp_member_check!="" || $moderate_action=="Ban" && $bp_member_check!=""){259 260 for ($i = 0; $i < count($bp_member_check); ++$i) {261 262 $userid=(int)$bp_member_check[$i];263 264 $user_info = get_userdata($userid);265 266 $username=$user_info->user_login;267 268 $useremail=$user_info->user_email;269 270 $wpdb->query( $wpdb->prepare("DELETE FROM ".$iprefix."usermeta WHERE user_id = %d", $userid) );271 272 $wpdb->query( $wpdb->prepare("DELETE FROM ".$iprefix."users WHERE ID = %d", $userid) );273 274 $wpdb->query( $wpdb->prepare("DELETE FROM ".$iprefix."bp_activity WHERE user_id = %d", $userid) );275 276 $wpdb->query( $wpdb->prepare("DELETE FROM ".$iprefix."bp_groups_members WHERE user_id = %d", $userid) );277 278 if($moderate_action=="Deny" && $bp_member_check!=""){279 //email member with custom message280 281 $denied_message=get_option('bprwg_denied_message');282 283 $the_email=$denied_message;284 285 $the_email=str_replace("[username]",$username,$the_email);286 287 wp_mail($useremail, 'Membership Denied', $the_email);288 }289 290 }291 292 }293 294 }295 296 297 298 $db_result_u = $wpdb->get_results( "Select a.* from ".$iprefix."users a LEFT OUTER JOIN ".$iprefix."usermeta b on a.ID=b.user_id where b.meta_key='bprwg_status' and meta_value<>'approved' and meta_value<>'denied' order by a.ID" );299 300 $members_count = count( $db_result_u );301 302 48 ?> 303 304 |305 306 <a <?php if ($view=="members"){?>style="font-weight:bold;"<?php } ?> href="<?php echo add_query_arg ('view', 'members');?>">New Member Requests (<?php echo $members_count;?>)</a>307 308 <?php }309 310 311 312 //ADMIN SETTINGS PAGE FORM*********************************************?>313 314 <hr>315 316 <?php317 318 if($moderate_action=="Approve" && $bp_member_check!=""){319 320 echo "<div id=message class=updated fade>Checked Members Approved!</div>";321 322 }elseif($moderate_action=="Deny" && $bp_member_check!=""){323 324 echo "<div id=message class=updated fade>Checked Members Denied and Deleted!</div>";325 326 }elseif($_POST['Moderate']!=""){327 328 echo "<div id=message class=updated fade>Please check at least 1 checkbox before pressing an action button!</div>";329 330 }elseif($_POST['Save']!="" || $_POST['save_privacy']!=""){331 332 echo "<div id=message class=updated fade>Settings Saved!</div>";333 334 }335 336 ?>337 338 <form name="bprwg" method="post">339 340 <?php341 342 if ( function_exists('wp_nonce_field') ) wp_nonce_field('cro_check');343 344 345 346 if ($view==""){347 348 $activate_message=get_option('bprwg_activate_message');349 350 if ($activate_message==""){351 352 $activate_message="<strong>Your membership account is awaiting approval by the site administrator.</strong> You will not be able to fully interact with the social aspects of this website until your account is approved. Once approved or denied you will receive an email notice.";353 354 }355 356 $approved_message=get_option('bprwg_approved_message');357 358 if ($approved_message==""){359 360 $approved_message="Hi [username],\n\nYour member account on ".get_bloginfo("url")." has been approved! You can now login and start interacting with the rest of the community...";361 362 }363 364 $denied_message=get_option('bprwg_denied_message');365 366 if ($denied_message==""){367 368 $denied_message="Hi [username],\n\nWe regret to inform you that your member account on ".get_bloginfo("url")." has been denied...";369 370 }371 372 ?>373 374 <input type="checkbox" id="bp_moderate" name="bp_moderate" onclick="show_messages();" value="yes" <?php if($bp_moderate=="yes"){?>checked<?php }?>/> <strong>Moderate New Members</strong> (Every new member will have to be approved by an administrator.)<br />375 376 <div id="bp_messages" style="display:none;">377 378 <table>379 380 <tr>381 382 <td align="right" valign="top">Activate & Profile Alert Message:</td>383 384 <td><textarea name="activate_message" style="width:500px;height:100px;"><?php echo $activate_message;?></textarea></td>385 386 </tr>387 388 <tr>389 390 <td align="right" valign="top">Account Approved Email:</td>391 392 <td><textarea name="approved_message" style="width:500px;height:100px;"><?php echo $approved_message;?></textarea></td>393 394 </tr>395 396 <tr>397 398 <td align="right" valign="top">Account Denied Email:</td>399 400 <td><textarea name="denied_message" style="width:500px;height:100px;"><?php echo $denied_message;?></textarea></td>401 402 </tr>403 404 <tr>405 406 <td></td>407 408 <td align="right">409 410 <table width="100%">411 412 <tr>413 414 <td>Short Code Key: [username]</td>415 416 <td align="right"><input type="submit" name="reset_messages" value="Reset Messages" onclick="return confirm('Are you sure you want to reset to the default messages?');" /></td>417 418 </tr>419 420 </table>421 422 </td>423 424 </tr>425 426 </table>427 428 </div>429 430 <script>431 432 function show_messages(){433 434 if(document.getElementById('bp_moderate').checked == true){435 436 document.getElementById('bp_messages').style.display='';437 438 }else{439 440 document.getElementById('bp_messages').style.display='none';441 442 }443 444 }445 446 <?php if($bp_moderate=="yes"){447 448 echo "document.getElementById('bp_messages').style.display='';";449 450 }?>451 452 </script>453 454 <?php //**************************************************455 456 //MANAGE GROUPS AND BLOGS?>457 458 <hr>459 460 <strong>Check groups and/or sites members can join at registration</strong><br />461 462 <table>463 464 <tr>465 466 <td valign="top">467 468 <table>469 470 <tr>471 472 <td><strong>BuddyPress Groups:</strong></td>473 474 </tr>475 476 <?php477 478 if(!is_array($bp_groups)){479 480 $bp_groups=array(0);481 482 }483 484 $db_result = $wpdb->get_results( "SELECT id,name FROM ".$iprefix."bp_groups where name <>'' order by name" );485 486 if ( count( $db_result ) > 0 ) {487 488 foreach( $db_result as $the_db_result ) {489 490 ?>491 492 <tr>493 494 <td>495 496 <input type="checkbox" name="bp_groups[]" value="<?php echo $the_db_result->id;?>" <?php if(in_array($the_db_result->id, $bp_groups)){?>checked<?php }?>/> <?php echo $the_db_result->name;?>497 498 </td>499 500 </tr>501 502 <?php503 504 }505 506 }507 508 509 510 ?>511 512 </table>513 514 </td>515 516 <td width="100px"></td>517 518 <td valign="top">519 520 <table>521 522 <tr>523 524 <td><strong>WP Multi-Sites:</strong></td>525 526 </tr>527 528 <?php529 530 if(WP_ALLOW_MULTISITE==1){531 532 if(!is_array($bp_blogs)){533 534 $bp_blogs=array(0);535 536 }537 538 $db_result = $wpdb->get_results( "SELECT blog_id,path FROM ".$iprefix."blogs order by path" );539 540 if ( count( $db_result ) > 0 ) {541 542 foreach( $db_result as $the_db_result ) {543 544 545 546 $db_result_n = $wpdb->get_results( "SELECT option_value FROM ". $iprefix . $the_db_result->blog_id . "_options where option_name='blogname'" );547 548 if ( count( $db_result_n ) > 0 ) {549 550 foreach( $db_result_n as $the_db_result_n ) {551 552 ?>553 554 <tr>555 556 <td>557 558 <input type="checkbox" name="bp_blogs[]" value="<?php echo $the_db_result->blog_id;?>" <?php if($bp_blogs!=""){if( in_array( $the_db_result->blog_id, $bp_blogs) ) {?>checked<?php }} ?>/> <?php echo $the_db_result_n->option_value;?>559 560 </td>561 562 </tr>563 564 <?php565 566 }567 568 }569 570 }571 572 573 574 }575 576 }else{ ?>577 578 <tr><td>You do not have Multi-Site enabled. Refer to <a href="http://codex.wordpress.org/Create_A_Network">http://codex.wordpress.org/Create_A_Network</a> if you would like to set it up.</td></tr>579 580 <?php }?>581 582 </table>583 584 </td>585 586 </tr>587 588 </table>589 590 <br />591 592 <input type="submit" name="Save" value="Save Options" />593 594 <?php595 596 //Spam**********************************597 598 }elseif($view=="spam"){599 600 ?>601 602 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> <strong>Require members upload a real photo.</strong><br />603 604 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> <strong>Use a honey pot system.</strong><br />605 606 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> Ban honey pot violators automatically.<br />607 608 <strong>When a member is banned:</strong><br />609 610 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> Ban them with a cookie.<br />611 612 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> Ban them by their IP address.<br />613 614 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> Ban them by their email address ([email protected]).<br />615 616 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> Ban them from viewing the website, violators will be redirected to a 404 page.<br />617 618 <input type="submit" name="save_spam" value="Save" />619 620 <?php621 622 //Privacy**********************************623 624 625 }elseif($view=="privacy"){626 627 $privacy_network=get_option('bprwg_privacy_network');628 629 if ($privacy_network){630 631 $privacy_network="checked";632 633 }634 635 $privacy_network_exceptions=get_option('bprwg_privacy_network_exceptions');636 637 $privacy_profiles_limit=get_option('bprwg_privacy_profiles_limit');638 639 if ($privacy_profiles_limit){640 641 $privacy_profiles_limit="checked";642 643 }644 645 $privacy_profile_views=get_option('bprwg_privacy_profile_views');646 647 if($privacy_profile_views==""){648 649 $privacy_profile_views=5;650 651 }652 653 $private_profiles=get_option('private_profiles');654 655 if ($private_profiles){656 657 $private_profiles="checked";658 659 }660 661 ?>662 663 <input type="checkbox" name="privacy_network" value="1" <?php echo $privacy_network;?>/> Only registered or approved members can view BuddyPress pages (Private Network).664 665 <table>666 667 <tr>668 669 <td style="width:25px !important;"></td>670 671 <td>672 673 The following BP pages are an exception to above:<br />674 675 <?php $is_bp_dir = $bp->root_components;676 677 foreach ($is_bp_dir as $value) {678 679 if($value!="register" && $value!="search" && $value!="activate"){680 681 ?>682 683 <input type="checkbox" name="privacy_network_exceptions[]" value="<?php echo $value;?>" <?php if(is_array($privacy_network_exceptions)){if(in_array($value,$privacy_network_exceptions)){echo"checked";}}?>/> <?php echo ucfirst($value);?><br />684 685 <?php686 687 }688 689 }690 691 692 693 ?>694 695 </td>696 697 </tr>698 699 </table>700 701 <!--<input type="checkbox" name="privacy_profiles_limit" value="1" <?php echo $privacy_profiles_limit;?> /> Public can only view BuddyPress profiles <input type="text" name="privacy_profile_views" value="<?php echo $privacy_profile_views;?>" style="width:20px;" /> times before being forced to register.<br />702 703 <input type="checkbox" name="private_profiles" value="1" <?php echo $private_profiles;?>/> Give members an option to make their profile viewable by their friends only.<br />-->704 705 <input type="submit" name="save_privacy" value="Save" />706 707 <?php708 709 //MAPPING710 711 }elseif($view=="mapping"){ ?>712 713 <!--You can map WP Blogs to BP Groups so when a new member joins one they are automatically tied to the other. An example would be if you map Group A to Blog A, when a user joins Group A at registration they will automatically join Blog A or if a user joins Blog A they will automatically join Group A.-->714 715 Map blogs to blogs and/or groups and map groups to groups and/or blogs.<br /><br />716 717 <table>718 719 <tr>720 721 <td><strong>If some one joins:</strong></td>722 723 <td></td>724 725 <td><strong>They will automatically join:</strong></td>726 727 </tr>728 729 <tr>730 731 <td>732 733 <select name="user_join">734 735 <?php //groups736 737 $db_result = $wpdb->get_results( "SELECT id,name FROM ".$iprefix."bp_groups order by name" );738 739 if ( count( $db_result ) > 0 ) {740 741 foreach( $db_result as $the_db_result ) {?>742 743 <option value="<?php echo $the_db_result->id;?>">BP Group - <?php echo $the_db_result->name;?>744 745 <?php746 747 }748 749 }750 751 //blogs752 753 $db_result = $wpdb->get_results( "SELECT blog_id,path FROM ".$iprefix."blogs order by path" );754 755 if ( count( $db_result ) > 0 ) {756 757 foreach( $db_result as $the_db_result ) {758 759 $db_result_n = $wpdb->get_results( "SELECT option_value FROM ". $iprefix . $the_db_result->blog_id . "_options where option_name='blogname'" );760 761 if ( count( $db_result_n ) > 0 ) {762 763 foreach( $db_result_n as $the_db_result_n ) {?>764 765 <option type="checkbox" value="<?php echo $the_db_result->blog_id;?>">WP Blog - <?php echo $the_db_result_n->option_value;?>766 767 <?php768 769 }770 771 }772 773 }774 775 776 777 }?>778 779 </select>780 781 </td>782 783 <td>784 785 <select name="code_join">786 787 788 789 </select>790 791 </td>792 793 </tr>794 795 </table>796 797 798 799 800 801 <?php }else{802 803 ///New members requests*********************************************************804 805 if ($members_count > 0) { ?>806 807 Please approve or deny the following new members:808 809 <SCRIPT LANGUAGE="JavaScript">810 811 function bprwg_checkall(field){812 813 if(document.getElementById('bp_checkall').checked == true){814 815 checkAll(field)816 817 }else{818 819 uncheckAll(field)820 821 }822 823 }824 825 function checkAll(field)826 827 {828 829 for (i = 0; i < field.length; i++)830 831 field[i].checked = true ;832 833 }834 835 836 837 function uncheckAll(field)838 839 {840 841 for (i = 0; i < field.length; i++)842 843 field[i].checked = false ;844 845 }846 847 848 849 </script>850 851 <table cellpadding="3" cellspacing="3">852 853 <tr>854 855 <td><input type="checkbox" id="bp_checkall" onclick="bprwg_checkall(document.bprwg.bp_member_check);" name="checkall" /></td>856 857 <td><strong>Photo</strong></td>858 859 <td><strong>Name</strong></td>860 861 <?php862 863 $groups="";864 865 foreach ($bp_groups as $value) {866 867 $groups=$groups.",".$value;868 869 }870 871 if ($groups!=""){872 873 $groups="00".$groups;?>874 875 <td><strong>Requested Private Groups</strong></td>876 877 <?php } ?>878 879 <td><strong>Email</strong></td>880 881 <td><strong>Created</strong></td>882 883 <td><strong>IP Data</strong></td>884 885 </tr>886 887 <?php888 889 890 891 // We reuse the query from line 138892 893 foreach( $db_result_u as $the_db_result ) {894 895 $user_id=$the_db_result->ID;896 897 $author = new BP_Core_User( $user_id );898 899 //$userpic=$author->avatar;900 901 $userpic=$author->avatar_mini;902 903 $userlink=$author->user_url;904 905 $username=$author->fullname;906 907 //$userpic=bp_core_get_avatar( $user_id, 1 );908 909 $useremail=$the_db_result->user_email;910 911 $userregistered=$the_db_result->user_registered;912 913 $userip = get_user_meta( $user_id, 'bprwg_ip_address', true);914 915 if($bgc==""){916 917 $bgc="#ffffff";918 919 }else{920 921 $bgc="";922 923 }924 925 ?>926 927 <tr style="background:<?php echo $bgc;?> !important;">928 929 <td valign="top"><?php //echo $user_id; ?><input type="checkbox" id="bp_member_check" name="bp_member_check[]" value="<?php echo $user_id; ?>" /></td>930 931 <td valign="top"><a target="_blank" href="<?php echo $userlink; ?>"><?php echo $userpic?></a></td>932 933 <td valign="top"><strong><a target="_blank" href="<?php echo $userlink; ?>"><?php echo $username?></a></strong></td>934 935 <?php if ($groups!=""){ ?>936 937 <td valign="top">938 939 <?php940 941 942 943 $db_result = $wpdb->get_results( "select a.id,a.name from ".$iprefix."bp_groups a, ".$iprefix."bp_groups_members b where a.id=b.group_id and b.user_id=$user_id and a.id in (".$groups.") and a.status in ('semi','private') and b.is_confirmed=0" );944 945 if ( count( $db_result ) > 0 ) {946 947 foreach( $db_result as $the_db_result ) {948 949 $group_id = $the_db_result->id;950 951 $group_name = $the_db_result->name;952 953 ?>954 955 [<input checked="checked" type="radio" name="usergroup_<?php echo $user_id; ?>_<?php echo $group_id; ?>" value="approve" />Approve<input type="radio" name="usergroup_<?php echo $user_id; ?>_<?php echo $group_id; ?>" value="deny" />Deny<input type="radio" name="usergroup_<?php echo $user_id; ?>_<?php echo $group_id; ?>" value="ban" />Ban] <strong><?php echo $group_name; ?></strong><br />956 957 <?php958 959 }960 961 } else {962 963 echo "N/A";964 965 }966 967 968 969 ?>970 971 </td>972 973 <?php } ?>974 975 <td valign="top"><a href="mailto:<?php echo $useremail;?>"><?php echo $useremail;?></a></td>976 977 <td valign="top"><?php echo $userregistered;?></td>978 979 <td valign="top">980 <table>981 <tr>982 <td valign="top">983 <?php echo '<img src="http://api.hostip.info/flag.php?ip=' . $userip . '" / >' ?>984 </td>985 <td valign="top">986 <?php987 $response = wp_remote_get( 'http://api.hostip.info/get_html.php?ip=' . $userip );988 if(!is_wp_error( $response ) ) {989 $data = $response['body'];990 $data = str_replace("City:","<br>City:",$data);991 $data = str_replace("IP:","<br>IP:",$data);992 echo $data;993 }994 ?>995 </td>996 </tr>997 </table>998 </td>999 1000 </tr>1001 1002 <?php } ?>1003 1004 </table>1005 1006 1007 1008 <br />1009 1010 <input type="submit" name="Moderate" value="Approve" />1011 1012 <input type="submit" name="Moderate" value="Deny" onclick="return confirm('Are you sure you want to deny and delete the checked memeber(s)?');" />1013 1014 <input type="submit" name="Moderate" value="Ban" onclick="return confirm('Are you sure you want to ban and delete the checked memeber(s)?');" /><br /><br />1015 1016 *If you Ban a member they will not receive an email.1017 1018 <?php }else{1019 1020 echo "No new members to approve.";1021 1022 }1023 1024 } ?>1025 1026 </form>1027 1028 <br />1029 1030 For support please visit the <a target="_blank" href="http://webdevstudios.com/support/forum/buddypress-registration-options/">BP-Registration-Options Plugin Support Forum</a> | Version by <a href="http://webdevstudios.com">WebDevStudios.com</a><br />1031 1032 <a target="_blank" href="http://webdevstudios.com/support/wordpress-plugins/">Check out our other plugins</a> and follow <a target="_blank" href="http://twitter.com/webdevstudios">@WebDevStudios</a> and <a target="_blank" href="http://twitter.com/bmess">@bmess</a> on Twitter1033 1034 <?php }1035 1036 //ACCOUNT ACTIVATION ACTIONS*******************************************************************1037 1038 //ACCOUNT ACTIVATION ACTIONS*******************************************************************1039 1040 //ACCOUNT ACTIVATION ACTIONS*******************************************************************1041 1042 //ACCOUNT ACTIVATION ACTIONS*******************************************************************1043 1044 //ACCOUNT ACTIVATION ACTIONS*******************************************************************1045 1046 function bprwg_update_profile(){1047 1048 global $wpdb, $bp, $user_id, $blog_id, $iprefix;1049 1050 switch_to_blog(1);1051 1052 //Get Current User_ID1053 1054 //$userid = $bp->loggedin_user->id;1055 1056 //If not logged in they came from activation page1057 1058 if ($userid=="") {1059 1060 $key=$_GET['key'];1061 1062 if ($key!=""){1063 1064 if ( bp_account_was_activated() ) :1065 1066 $db_result = $wpdb->get_results( "select ID from ".$iprefix."users where user_activation_key='$key'" );1067 1068 if ( count( $db_result ) > 0 ) {1069 1070 foreach( $db_result as $the_db_result ) {1071 1072 $userid = $the_db_result->ID;1073 1074 $from_reg = 'yes';1075 1076 }1077 1078 }1079 1080 endif;1081 1082 }1083 1084 }1085 1086 //Can only pass if user_id exists1087 1088 if ($userid!="") {1089 1090 $user_info = get_userdata($userid);1091 1092 $username=$user_info->user_login;1093 1094 $useremail=$user_info->user_email;1095 1096 //BLOGS1097 1098 $bp_blogs=get_option('bprwg_blogs');1099 1100 if($bp_blogs!=""){1101 1102 $userblogs=get_option('bprwg_newmember_blogs_'.$useremail);1103 1104 if($userblogs!=""){1105 1106 $arr_userblogs = explode(",", $userblogs);1107 1108 for($i = 0; $i < count($arr_userblogs); $i++){1109 1110 $blog_id = $arr_userblogs[$i];1111 1112 1113 1114 $db_result = $wpdb->get_results( "SELECT option_value FROM ".$iprefix.$blog_id."_options where option_name='default_role'" );1115 1116 if ( count( $db_result ) > 0 ) {1117 1118 foreach( $db_result as $the_db_result ) {1119 1120 $default_role = $the_db_result->option_value;1121 1122 add_user_to_blog($blog_id, $userid, $default_role);1123 1124 }1125 1126 }1127 1128 1129 1130 }1131 1132 }1133 1134 delete_option('bprwg_newmember_blogs_'.$useremail);1135 1136 }1137 1138 //GROUPS1139 1140 $bp_groups=get_option('bprwg_groups');1141 1142 if($bp_groups!=""){1143 1144 $usergroups=get_option('bprwg_newmember_groups_'.$useremail);1145 1146 1147 1148 $db_result = $wpdb->get_results( "select id,status,name,slug from ".$iprefix."bp_groups where id in ($usergroups) order by name" );1149 1150 if ( count( $db_result ) > 0 ) {1151 1152 foreach( $db_result as $the_db_result ) {1153 1154 1155 1156 if( $the_db_result->status == 'semi' || $the_db_result->status == 'private' ) {1157 1158 $is_confirmed=0;1159 1160 } else {1161 1162 $is_confirmed=1;1163 1164 }1165 1166 //if not already in group then add to group1167 1168 1169 1170 1171 1172 $db_result_n = $wpdb->get_results( 'select id from ' . $iprefix . 'bp_groups_members where group_id=' . $the_db_result->id . ' and user_id=' . $userid );1173 1174 if ( count( $db_result_n ) == 0 ) {1175 1176 //add memebr to group and send group confirmation if need be1177 1178 $wpdb->query( $wpdb->prepare(1179 1180 'insert into '. $iprefix . "bp_groups_members( group_id, user_id, inviter_id, user_title, date_modified, comments, is_confirmed ) values ( $the_db_result->id, $userid, 0, '', now(), '', $is_confirmed )"1181 1182 ) );1183 1184 if ($is_confirmed==0){1185 1186 $group_email=$group_email.$username." wants to join the group [".$the_db_result->name."] - ".get_bloginfo("url")."/groups/".$the_db_result->slug."/admin/membership-requests.\n\n";1187 1188 }1189 1190 }1191 1192 1193 1194 1195 1196 }1197 1198 }1199 1200 1201 1202 delete_option('bprwg_newmember_groups_'.$useremail);1203 1204 }1205 1206 //for member moderation after member activation...1207 1208 if ($from_reg="yes"){1209 1210 $bp_moderate=get_option('bprwg_moderate');1211 1212 if ($bp_moderate=="yes"){1213 1214 //add/update usermeta status to activated1215 1216 update_usermeta($userid, 'bprwg_status', 'activated');1217 1218 update_usermeta($userid, 'bprwg_ip_address', $_SERVER['REMOTE_ADDR']);1219 1220 1221 1222 //update wp_users to deleted=1, this will prevent member from being listed in member directory but not actually delete them. once appoved will be updated back to 0, if denied will fully delete account1223 1224 $sql="update ".$iprefix."users set deleted=1 where ID=$userid";1225 1226 $wpdb->query($wpdb->prepare($sql));1227 1228 //fire off email to admin about new memebr with links to accept or reject1229 1230 $mod_email=$username." would like to become a member of your website, to accept or reject their request please go to ".get_bloginfo("url")."/wp-admin/admin.php?page=bp-registration-options&view=members \n\n";1231 1232 }1233 1234 //delete user_activation_key after activation1235 1236 $sql="update ".$iprefix."users set user_activation_key='' where ID=$userid";1237 1238 $wpdb->query($wpdb->prepare($sql));1239 1240 }1241 1242 //Send Emails for new member or request access to goups1243 1244 if($group_email!="" || $mod_email!=""){1245 1246 $the_email="";1247 1248 if($mod_email!=""){1249 1250 $the_email.=$mod_email;1251 1252 }1253 1254 if($mod_email!=""){1255 1256 $the_email.=$group_email;1257 1258 }1259 1260 $admin_email = get_option('admin_email');1261 1262 wp_mail($admin_email, 'New Member Request', $the_email);1263 1264 }1265 1266 }1267 1268 }1269 1270 1271 1272 //called from activation hook1273 1274 function bprwg_activate($userid){1275 1276 global $wpdb, $bp, $blog_id, $iprefix;1277 1278 //get key from querystring and update user_activation_key in wp_users (has already been deleted on activation, put back in so we can grab it after bp activation stuff runs then delete it again)1279 1280 $key=$_GET['key'];1281 1282 $sql="update ".$iprefix."users set user_activation_key='$key' where ID=$userid";1283 1284 $wpdb->query($wpdb->prepare($sql));1285 1286 //Hide any by activity1287 1288 $sql="update ".$iprefix."bp_activity set hide_sitewide=1 where user_id=$userid";1289 1290 $wpdb->query($wpdb->prepare($sql));1291 1292 }1293 1294 //add_action( 'wpmu_activate_user', 'bprwg_activate');//Only works on MS1295 1296 1297 1298 add_action( 'bp_core_activate_account', 'bprwg_activate');1299 1300 add_filter('bp_before_activate_content', 'bprwg_update_profile');1301 1302 1303 1304 1305 1306 //MODERATION - New member alert message and redirect*****************************1307 1308 function bprwg_approve_message(){1309 1310 global $wpdb;1311 1312 //check if moderation is on1313 1314 $bp_moderate=get_option('bprwg_moderate');1315 1316 if ($bp_moderate=="yes"){1317 1318 $showit="yes";1319 1320 if(strrpos($_SERVER['REQUEST_URI'],"/activate")!== false){1321 1322 $showit="no";1323 1324 global $bp;1325 1326 $userid = $bp->loggedin_user->id ;1327 1328 if ( bp_account_was_activated() ) :1329 1330 $showit="yes";1331 1332 $hidelogout="yes";1333 1334 endif;1335 1336 }1337 1338 if($showit=="yes"){1339 1340 $activate_message=get_option('bprwg_activate_message');1341 1342 echo '<div id="message" class="error"><p>'.$activate_message.'<br>';1343 1344 if($hidelogout!="yes"){1345 1346 echo '<a href="'.wp_logout_url( get_bloginfo("url") ).'" title="Logout">Logout</a>';1347 1348 }1349 1350 echo '</p></div>';1351 1352 }1353 1354 }1355 1356 }1357 1358 1359 1360 //INIT***************************************1361 1362 function bprwg_redirect(){1363 1364 global $wpdb, $bp;1365 1366 //add/remove users to/from blogs1367 1368 if($_POST['Update_Blog']!=""){1369 1370 global $bp, $blog_id, $user_id, $iprefix;1371 1372 $userid = $bp->loggedin_user->id ;1373 1374 if($userid!=""){1375 1376 $bp_blogs=get_option('bprwg_blogs');1377 1378 if($bp_blogs!=""){1379 1380 $bp_blogs_form=$_POST['bprwg_blogs'];1381 1382 //echo "bp_blogs_form:".$bp_blogs_form;1383 1384 $arr_bp_blogs = explode(",", $bp_blogs);1385 1386 for($i = 0; $i < count($arr_bp_blogs); $i++){1387 1388 $iblog_id = $arr_bp_blogs[$i];1389 1390 //echo $iblog_id."<br>";1391 1392 if($bp_blogs_form!=""){1393 1394 //if checked1395 1396 if(in_array($iblog_id, $bp_blogs_form)){1397 1398 //echo $iblog_id." checked<br>";1399 1400 //if already a member skip, else add1401 1402 $sql="SELECT meta_value FROM ".$iprefix."usermeta where meta_key='wp_".$iblog_id."_capabilities' and user_id=".$userid."";1403 1404 $db_result = $wpdb->get_results($sql);1405 1406 if ( count( $db_result ) > 0 ) {1407 1408 //echo "already joined";1409 1410 }else{1411 1412 $sql="SELECT option_value FROM ".$iprefix.$iblog_id."_options where option_name='default_role'";1413 1414 //echo $sql."<br>";1415 1416 $db_result = $wpdb->get_results($sql);1417 1418 if ( count( $db_result ) > 0 ) {1419 1420 foreach( $db_result as $the_db_result ) {1421 1422 $default_role = $the_db_result->option_value;1423 1424 //echo "default_role: ".$default_role."<br>";1425 1426 //echo "blog_id: ".$iblog_id."<br>";1427 1428 //echo "userid: ".$userid."<br>";1429 1430 add_user_to_blog($iblog_id, $userid, $default_role);1431 1432 }1433 1434 }1435 1436 }1437 1438 //if not checked1439 1440 }else{1441 1442 $removethem="yes";1443 1444 }1445 1446 }else{1447 1448 $removethem="yes";1449 1450 }1451 1452 if ($removethem=="yes"){1453 1454 //echo $iblog_id." not checked<br>";1455 1456 $sql="SELECT meta_value FROM ".$iprefix."usermeta where meta_key='wp_".$iblog_id."_capabilities' and user_id=".$userid."";1457 1458 $db_result = $wpdb->get_results($sql);1459 1460 if ( count( $db_result ) > 0 ) {1461 1462 foreach( $db_result as $the_db_result ) {1463 1464 $default_role = $the_db_result->meta_value;1465 1466 //echo $default_role."<br>";1467 1468 if($default_role > 9){1469 1470 //$bprwg_error="?m=10";1471 1472 //echo $bprwg_error."<br>";1473 1474 }else{1475 1476 //echo "Remove blog<br>";1477 1478 //echo "userid:".$userid."<br>";1479 1480 //echo "blog_id:".$iblog_id."<br>";1481 1482 remove_user_from_blog($userid, $iblog_id);1483 1484 }1485 1486 }1487 1488 }1489 1490 $removethem="no";1491 1492 }1493 1494 }1495 1496 echo '<meta http-equiv="refresh" content="0;url='.$bprwg_error.'" />';1497 1498 exit();1499 1500 }1501 1502 }1503 1504 }1505 1506 1507 1508 //redirect from wp-signup.php1509 1510 if(strrpos($_SERVER['REQUEST_URI'],"/wp-signup.php")!== false ){1511 1512 $url=get_option('siteurl')."/register";1513 1514 wp_redirect($url, 301);1515 1516 //if for some reason wp_redirect isn't working.(maybe other plugins runing before with output)1517 1518 echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';1519 1520 exit();1521 1522 }1523 1524 1525 1526 $url = $_SERVER['REQUEST_URI'];1527 1528 $is_bp=$url;1529 1530 $is_bp=str_replace("?","/",$is_bp);1531 1532 $is_bp=substr($is_bp,0,strpos($is_bp,'/',1));1533 1534 if($is_bp==""){1535 1536 $is_bp=$url;1537 1538 }1539 1540 $is_bp=str_replace("/","",$is_bp);1541 1542 1543 1544 //redirect profile viewer X times to registation1545 1546 $privacy_profile=get_option('bprwg_privacy_profile_views');1547 1548 $profile_id=$bp->displayed_user->id;1549 1550 //echo "<hr>here: ".$profile_id."<hr>";1551 1552 if($privacy_profile!="" && $profile_id!="" && $bp->loggedin_user->id=="0"){1553 1554 $privacy_profiles_limit=get_option('bprwg_privacy_profiles_limit');1555 1556 $my_profile_view=6;1557 1558 if($my_profile_view >= $privacy_profiles_limit){1559 1560 $url=get_option('siteurl')."/register/?profile_views=true";1561 1562 wp_redirect($url);1563 1564 echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';1565 1566 exit();1567 1568 }1569 1570 }1571 1572 1573 1574 //Show Private network message on registration page1575 1576 $privacy_network=get_option('bprwg_privacy_network');1577 1578 if($privacy_network){1579 1580 add_filter('bp_before_container', 'bprwg_message_private_network');1581 1582 }1583 1584 $bp_moderate=get_option('bprwg_moderate');1585 1586 //check if moderation or private network is on1587 1588 if ($bp_moderate=="yes" || $privacy_network!=""){1589 1590 //only restrict buddypress pages1591 1592 $is_bp_dir = $bp->root_components;1593 1594 if (in_array($is_bp, $is_bp_dir) && $is_bp!="register" && $is_bp!="activate") {1595 1596 //check if logged in1597 1598 $userid = $bp->loggedin_user->id;1599 1600 if ($userid!="" || $privacy_network!=""){1601 1602 if ($userid!=""){1603 1604 $user_info = get_userdata($userid);1605 1606 $username=$user_info->user_login;1607 1608 $url="/members/".$username."/profile/";1609 1610 //check if approved or grandfathered in (already had account when plugin activated)1611 1612 $status = get_usermeta($userid, 'bprwg_status');1613 1614 if($status!="approved" && $status!=""){1615 1616 //check if allowed buddypress pages1617 1618 if($url==$_SERVER['REQUEST_URI'] || strrpos($_SERVER['REQUEST_URI'],$url."change-avatar")!== false || strrpos($_SERVER['REQUEST_URI'],$url."edit")!== false || strrpos($_SERVER['REQUEST_URI'],"wp-login.php?action=logout")!== false){1619 1620 //add_filter('bp_before_profile_menu', 'bprwg_approve_message');1621 1622 add_filter('bp_before_container', 'bprwg_approve_message');1623 1624 }else{1625 1626 $url=get_option('siteurl').$url;1627 1628 wp_redirect($url);1629 1630 echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';//if for some reason wp_redirect isn't working.(maybe other plugins runing before with output)1631 1632 exit();1633 1634 }1635 1636 }1637 1638 }else{1639 1640 $privacy_network_exceptions=get_option('bprwg_privacy_network_exceptions');1641 1642 if(!is_array($privacy_network_exceptions)){1643 1644 $privacy_network_exceptions=array();1645 1646 }1647 1648 if(!in_array($is_bp, $privacy_network_exceptions)){1649 1650 $url=get_option('siteurl')."/register/?private=true";1651 1652 wp_redirect($url);1653 1654 echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';1655 1656 exit();1657 1658 }1659 1660 }1661 1662 }1663 1664 }1665 1666 }1667 1668 }1669 1670 add_action('init', 'bprwg_redirect', -1);1671 1672 add_filter('bp_after_activate_content', 'bprwg_approve_message');1673 1674 1675 1676 1677 1678 function bprwg_message_private_network() {1679 1680 if($_GET['private']=='true'){1681 1682 echo '<div id="message" class="error"><p>This is a private network. You must register first before fully interacting with the rest of the community.';1683 1684 echo '</p></div>';1685 1686 }1687 1688 }1689 1690 1691 1692 //ADMIN DASHBOARD MESSAGE******************************************************1693 1694 function bprwg_admin_msg() {1695 1696 global $wpdb, $iprefix;1697 1698 switch_to_blog(1);1699 //Delete any un-activated accounts over 7 days old1700 $thedate=date('Y-m-d G:i:s');1701 $oneWeekAgo = strtotime ( '-1 week' , strtotime ( $thedate ) ) ;1702 $thedate=date ( 'Y-m-j G:i:s' , $oneWeekAgo );1703 $db_result = $wpdb->get_results("Select user_email from ".$iprefix."signups where active=0 and registered < '".$thedate."'");1704 if ( count( $db_result ) > 0 ) {1705 foreach( $db_result as $the_db_result ) {1706 $email=$the_db_result->user_email;1707 $wpdb->get_results( "delete from ".$wpdb->prefix."options where option_name = 'bprwg_newmember_groups_".$email."' or option_name = 'bprwg_newmember_blogs_".$email."'" );1708 $wpdb->get_results( "delete from ".$iprefix."signups where active=0 and user_email='".$email."'" );1709 }1710 }1711 if (current_user_can('manage_options')){1712 1713 $bp_moderate=get_option('bprwg_moderate');1714 1715 if ($bp_moderate=="yes"){1716 1717 $db_result = $wpdb->get_results( "Select a.* from ".$iprefix."users a LEFT OUTER JOIN ".$iprefix."usermeta b on a.ID=b.user_id where b.meta_key='bprwg_status' and meta_value<>'approved' and meta_value<>'denied' order by a.ID" );1718 1719 if ( count( $db_result ) > 0 ) {1720 1721 1722 1723 if( count( $db_result ) != 1 ){1724 1725 $s = 's';1726 1727 }1728 1729 echo '<div class="error"><p>You have <a href="'.get_bloginfo("url").'/wp-admin/admin.php?page=bp-registration-options&view=members"><strong>'.count( $db_result ).' new member request'.$s.'</strong></a> that you need to approve or deny. Please <a href="'.get_bloginfo("url").'/wp-admin/admin.php?page=bp-registration-options&view=members">click here</a> to take action.</p></div>';1730 1731 }1732 1733 1734 1735 }1736 1737 }1738 1739 }1740 1741 function bprwg_admin_init() {1742 1743 add_action('admin_notices', 'bprwg_admin_msg');1744 1745 }1746 1747 add_action( 'admin_init', 'bprwg_admin_init' );1748 1749 1750 1751 //REGISTRATION FORM*******************************************************************************1752 1753 function bprwg_register_page(){1754 1755 global $wpdb, $bp, $user_id, $blog_id, $iprefix;1756 1757 //GROUPS1758 1759 $bp_groups=get_option('bprwg_groups');1760 1761 if($bp_groups!=""){1762 1763 1764 1765 $db_result = $wpdb->get_results( "SELECT id,name FROM ".$iprefix."bp_groups where id in ($bp_groups) order by name" );1766 1767 if ( count( $db_result ) > 0 ) {1768 1769 ?>1770 1771 <div id="bp_registration-options-groups" class="register-section">1772 1773 <strong>Group(s)</strong><br />1774 1775 <?php foreach( $db_result as $the_db_result ): ?>1776 1777 <input type="checkbox" name="bprwg_groups[]" value="<?php echo $the_db_result->id; ?>" /> <?php echo $the_db_result->name; ?> 1778 1779 <?php endforeach; ?>1780 1781 <br />Check one or more groups you would like to join.</div>1782 1783 <?php1784 1785 }1786 1787 1788 1789 }1790 1791 //BLOGS1792 1793 $bp_blogs=get_option('bprwg_blogs');1794 1795 if($bp_blogs!=""){1796 1797 ?>1798 1799 <div id="bp_registration-options-blogs">1800 1801 <strong>Blog(s)</strong><br />1802 1803 <?php1804 1805 $arr_bp_blogs = explode(",", $bp_blogs);1806 1807 for($i = 0; $i < count($arr_bp_blogs); $i++){1808 1809 $blog_id = $arr_bp_blogs[$i];1810 1811 1812 1813 $db_result = $wpdb->get_results( "SELECT option_value FROM ".$iprefix.$blog_id."_options where option_name='blogname'" );1814 1815 if ( count( $db_result ) > 0 ) {1816 1817 foreach( $db_result as $the_db_result ) {1818 1819 ?>1820 1821 <input type="checkbox" name="bprwg_blogs[]" value="<?php echo $blog_id; ?>" /> <?php echo $the_db_result->option_value; ?> 1822 1823 <?php1824 1825 }1826 1827 }1828 1829 }1830 1831 echo "<br />Check one or more blogs you would like to join.</div>";1832 1833 }1834 1835 //captcha1836 1837 }1838 1839 add_filter('bp_before_registration_submit_buttons', 'bprwg_register_page');1840 1841 1842 1843 //REGISTRATION ACTIONS*************************************************************1844 1845 function bprwg_register_save(){1846 1847 global $wpdb;1848 1849 switch_to_blog(1);1850 1851 $iemail=$_POST['signup_email'];1852 1853 //echo $iemail;1854 1855 $bp_groups=$_POST['bprwg_groups'];1856 1857 if($bp_groups!=""){1858 1859 $bp_groups_str = implode(",", $bp_groups);1860 1861 update_option('bprwg_newmember_groups_'.$iemail, $bp_groups_str);1862 1863 }1864 1865 $bp_blogs=$_POST['bprwg_blogs'];1866 1867 if($bp_blogs!=""){1868 1869 $bp_blogs_str = implode(",", $bp_blogs);1870 1871 update_option('bprwg_newmember_blogs_'.$iemail, $bp_blogs_str);1872 1873 }1874 1875 //exit();1876 1877 }1878 1879 add_action( 'bp_complete_signup', 'bprwg_register_save' );1880 1881 1882 1883 1884 1885 //Member Profile Page (ADD BLOGS)*******************************************1886 1887 function bprwg_blog_menu(){1888 1889 global $wpdb, $bp, $iprefix;1890 1891 if ( bp_is_my_profile() ) :1892 1893 $bp_blogs=get_option('bprwg_blogs');1894 1895 if($bp_blogs!=""){?>1896 1897 <div id="bprwg_manage_group_blogs">1898 1899 <b>Manage Blog(s):</b>1900 1901 <?php if($_GET['m']!=""){1902 1903 echo "<div id='bprwg_manage_message'>";1904 1905 if($_GET['m']=="10"){1906 1907 echo "Dude?!?! Your an admin why are you trying to remove yourself from your blogs??? If you really wanna do this use the backend... Ya heard??!?!";1908 1909 }else{1910 1911 echo "Blog(s) updated!";1912 1913 }1914 1915 echo "</div>";1916 1917 }?>1918 1919 <p>*Check or uncheck the blog(s) you would like to be apart of:</p>1920 1921 <form action="" method="post">1922 1923 <?php //form posts to bprwg_redirect()1924 1925 $userid = $bp->loggedin_user->id ;1926 1927 $arr_bp_blogs = explode(",", $bp_blogs);1928 1929 for($i = 0; $i < count($arr_bp_blogs); $i++){1930 1931 $blog_id = $arr_bp_blogs[$i];1932 1933 $checked="";1934 1935 $sql="SELECT meta_value FROM ".$iprefix."usermeta where meta_key='wp_".$blog_id."_capabilities' and user_id=".$userid."";1936 1937 //echo $sql."<br>";1938 1939 $db_result = $wpdb->get_results($sql);1940 1941 if ( count( $db_result ) > 0 ) {1942 1943 $checked="checked";1944 1945 }1946 1947 $sql="SELECT option_value FROM ".$iprefix.$blog_id."_options where option_name='blogname'";1948 1949 //echo $sql;1950 1951 $db_result = $wpdb->get_results( $sql );1952 1953 if ( count( $db_result ) > 0 ) {1954 1955 echo "<ul id='bprwg_manage_group_blogs_checks'>";1956 1957 foreach( $db_result as $the_db_result ) {?>1958 1959 <li><input type="checkbox" name="bprwg_blogs[]" value="<?php echo $blog_id; ?>" <?php echo $checked; ?>/> <?php echo $the_db_result->option_value; ?></li>1960 1961 <?php1962 1963 }1964 1965 echo "</ul>";1966 1967 }1968 1969 }1970 1971 ?>1972 1973 <input type="submit" name="Update_Blog" value="Update" />1974 1975 </form><br />1976 1977 </div>1978 1979 <?php1980 1981 }1982 1983 endif;1984 1985 }1986 1987 add_filter( 'bp_before_member_blogs_content', 'bprwg_blog_menu');1988 ?> -
bp-registration-options/trunk/loader.php
r298940 r615824 2 2 /* 3 3 Plugin Name: BP-Registration-Options 4 Plugin URI: http://webdevstudios.com/support/wordpress-plugins/buddypress-registration-options/ 5 Description: BuddyPress plugin that allows for new member moderation, if moderation is switched on any new members will be blocked from interacting with any buddypress elements (except editing their own profile and uploading their avatar) and will not be listed in any directory until an admin approves or denies their account. Plugin also allows new members to join one or more predefined groups or blogs at registration. 6 Version: 3.0.3 7 Requires at least: WordPress 2.9.1 / BuddyPress 1.2 8 Tested up to: WordPress 3.0.1 / BuddyPress 1.2.5 9 Author: Brian Messenlehner of WebDevStudios.com 4 Plugin URI: http://wordpress.org/extend/plugins/bp-registration-options/ 5 Description: BuddyPress plugin that allows for new member moderation, if moderation is switched on any new members will be blocked from interacting with any buddypress elements (except editing their own profile and uploading their avatar) and will not be listed in any directory until an admin approves or denies their account. 6 Version: 4.0 7 Author: Brian Messenlehner of WebDevStudios 10 8 Author URI: http://webdevstudios.com/about/brian-messenlehner/ 9 Licence: GPLv3 11 10 */ 12 11 13 /* Only load code that needs BuddyPress to run once BP is loaded and initialized. */ 14 function bp_registration_options_init() { 15 require( dirname( __FILE__ ) . '/bp-registration-options.php' ); 12 define( 'BP_REGISTRATION_OPTIONS_VERSION', '4.0' ); 13 14 /** 15 * Loads BP Registration Options files only if BuddyPress is present 16 * 17 * @package BP-Registration-Options 18 * 19 */ 20 function wds_bp_registration_options_init() { 21 require( dirname( __FILE__ ) . '/bp-registration-options.php' ); 22 $bp_registration_options = new BP_Registration_Options; 16 23 } 17 add_action( 'bp_init', 'bp_registration_options_init' ); 18 //set $wpdb->prefix back to wp_ for MS 19 $iprefix=$wpdb->prefix; 20 $iprefix=str_replace("_".$blog_id,"",$iprefix); 24 add_action( 'bp_include', 'wds_bp_registration_options_init' ); 21 25 ?> -
bp-registration-options/trunk/readme.txt
r298940 r615824 1 1 === BuddyPress Registration Options === 2 2 3 Contributors: Messenlehner 3 Contributors: Messenlehner, webdevstudios 4 4 5 5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056 … … 7 7 Tags: buddypress, wpmu, wpms, plugin, admin, moderation, registration, groups, blogs, new members, buddypress private network, buddypress spam 8 8 9 Requires at least: 2.69 Requires at least: 3.0 10 10 11 Tested up to: 3. 011 Tested up to: 3.5 12 12 13 Stable tag: 3.0.3 13 Stable tag: 4.0.0 14 15 License: GPLv2 14 16 15 17 Moderate new BuddyPress members, fight BuddyPress spam, set BuddyPress Groups or Blogs/Sites new members can join on the registration page. … … 21 23 22 24 23 This WordPress BuddyPress plugin that allows for new member moderation, if moderation is turned on from the admin settings page, any new members will be blocked from interacting with any buddypress elements (except editing their own profile and uploading their avatar) and will not be listed in any directory until an administrator approves or denies their account. This plugin also creates bp profile field checkbox groups on the /register page from checked off groups or blogs in the admin settings section so any new members can join one or more groups or blogs that you specify at registration.If moderation is turned on admins can create custom display messages and email alert messages for approved or denied accounts. When admin approves or denies, custom emails get sent out to new members telling them they were approved or denied.25 This WordPress BuddyPress plugin that allows for new member moderation, if moderation is turned on from the admin settings page, any new members will be blocked from interacting with any buddypress elements (except editing their own profile and uploading their avatar) and will not be listed in any directory until an administrator approves or denies their account. If moderation is turned on admins can create custom display messages and email alert messages for approved or denied accounts. When admin approves or denies, custom emails get sent out to new members telling them they were approved or denied. 24 26 25 27 … … 54 56 == Changelog == 55 57 58 = 4.0.0 = 59 60 * Revamp of entire plugin. Stripped out features for joining particular groups at registration so you may not want to upgrade if you are dependent on these features. 61 56 62 = 3.0.3 = 57 63 … … 80 86 81 87 * First official release 88 89 90 == Upgrade Notice == 91 92 = 4.0.0 = 93 94 * Revamp of entire plugin. Stripped out features for joining particular groups at registration so you may not want to upgrade if you are dependent on these features. 82 95 83 96
Note: See TracChangeset
for help on using the changeset viewer.